@@ -23,7 +23,9 @@ public function configure(Recipe $recipe, $vars)
23
23
$ this ->write ('Added environment variable defaults ' );
24
24
25
25
$ this ->configureEnvDist ($ recipe , $ vars );
26
- $ this ->configurePhpUnit ($ recipe , $ vars );
26
+ if (!file_exists (getcwd ().'/.env.test ' )) {
27
+ $ this ->configurePhpUnit ($ recipe , $ vars );
28
+ }
27
29
}
28
30
29
31
public function unconfigure (Recipe $ recipe , $ vars )
@@ -34,32 +36,34 @@ public function unconfigure(Recipe $recipe, $vars)
34
36
35
37
private function configureEnvDist (Recipe $ recipe , $ vars )
36
38
{
37
- $ distenv = getcwd ().'/.env.dist ' ;
38
- if (!is_file ($ distenv ) || $ this ->isFileMarked ($ recipe , $ distenv )) {
39
- return ;
40
- }
41
-
42
- $ data = '' ;
43
- foreach ($ vars as $ key => $ value ) {
44
- $ value = $ this ->evaluateValue ($ value );
45
- if ('# ' === $ key [0 ] && is_numeric (substr ($ key , 1 ))) {
46
- $ data .= '# ' .$ value ."\n" ;
39
+ foreach (['.env.dist ' , '.env ' ] as $ file ) {
40
+ $ env = getcwd ().'/ ' .$ file ;
41
+ if (!is_file ($ env )) {
42
+ continue ;
43
+ }
47
44
45
+ if ($ this ->isFileMarked ($ recipe , $ env )) {
48
46
continue ;
49
47
}
50
48
51
- $ value = $ this ->options ->expandTargetDir ($ value );
52
- if (false !== strpbrk ($ value , " \t\n&! \"" )) {
53
- $ value = '" ' .str_replace (['\\' , '" ' , "\t" , "\n" ], ['\\\\' , '\\" ' , '\t ' , '\n ' ], $ value ).'" ' ;
49
+ $ data = '' ;
50
+ foreach ($ vars as $ key => $ value ) {
51
+ $ value = $ this ->evaluateValue ($ value );
52
+ if ('# ' === $ key [0 ] && is_numeric (substr ($ key , 1 ))) {
53
+ $ data .= '# ' .$ value ."\n" ;
54
+
55
+ continue ;
56
+ }
57
+
58
+ $ value = $ this ->options ->expandTargetDir ($ value );
59
+ if (false !== strpbrk ($ value , " \t\n&! \"" )) {
60
+ $ value = '" ' .str_replace (['\\' , '" ' , "\t" , "\n" ], ['\\\\' , '\\" ' , '\t ' , '\n ' ], $ value ).'" ' ;
61
+ }
62
+ $ data .= "$ key= $ value \n" ;
54
63
}
55
- $ data .= "$ key= $ value \n" ;
56
- }
57
- if (!file_exists (getcwd ().'/.env ' )) {
58
- copy ($ distenv , getcwd ().'/.env ' );
64
+ $ data = $ this ->markData ($ recipe , $ data );
65
+ file_put_contents ($ env , $ data , FILE_APPEND );
59
66
}
60
- $ data = $ this ->markData ($ recipe , $ data );
61
- file_put_contents ($ distenv , $ data , FILE_APPEND );
62
- file_put_contents (getcwd ().'/.env ' , $ data , FILE_APPEND );
63
67
}
64
68
65
69
private function configurePhpUnit (Recipe $ recipe , $ vars )
0 commit comments