@@ -54,17 +54,11 @@ public function handle(): int
54
54
$ shared_extensions = implode (', ' , $ craft ['shared-extensions ' ] ?? []);
55
55
$ libs = implode (', ' , $ craft ['libs ' ]);
56
56
57
- // init log
58
- if (file_exists (WORKING_DIR . '/craft.log ' )) {
59
- unlink (WORKING_DIR . '/craft.log ' );
60
- }
61
-
62
57
// craft doctor
63
58
if ($ craft ['craft-options ' ]['doctor ' ]) {
64
59
$ retcode = $ this ->runCommand ('doctor ' , '--auto-fix ' );
65
60
if ($ retcode !== 0 ) {
66
61
$ this ->output ->writeln ('<error>craft doctor failed</error> ' );
67
- $ this ->log ("craft doctor failed with code: {$ retcode }" , true );
68
62
return static ::FAILURE ;
69
63
}
70
64
}
@@ -73,7 +67,6 @@ public function handle(): int
73
67
$ retcode = $ this ->runCommand ('install-pkg ' , 'go-xcaddy ' );
74
68
if ($ retcode !== 0 ) {
75
69
$ this ->output ->writeln ('<error>craft go-xcaddy failed</error> ' );
76
- $ this ->log ("craft: spc install-pkg go-xcaddy failed with code: {$ retcode }" , true );
77
70
return static ::FAILURE ;
78
71
}
79
72
}
@@ -82,7 +75,6 @@ public function handle(): int
82
75
$ retcode = $ this ->runCommand ('install-pkg ' , 'zig ' );
83
76
if ($ retcode !== 0 ) {
84
77
$ this ->output ->writeln ('<error>craft zig failed</error> ' );
85
- $ this ->log ("craft: spc install-pkg zig failed with code: {$ retcode }" , true );
86
78
return static ::FAILURE ;
87
79
}
88
80
}
@@ -103,7 +95,6 @@ public function handle(): int
103
95
$ retcode = $ this ->runCommand ('download ' , ...$ args );
104
96
if ($ retcode !== 0 ) {
105
97
$ this ->output ->writeln ('<error>craft download failed</error> ' );
106
- $ this ->log ('craft download failed with code: ' . $ retcode , true );
107
98
return static ::FAILURE ;
108
99
}
109
100
}
@@ -115,7 +106,6 @@ public function handle(): int
115
106
$ retcode = $ this ->runCommand ('build ' , ...$ args );
116
107
if ($ retcode !== 0 ) {
117
108
$ this ->output ->writeln ('<error>craft build failed</error> ' );
118
- $ this ->log ('craft build failed with code: ' . $ retcode , true );
119
109
return static ::FAILURE ;
120
110
}
121
111
}
@@ -129,18 +119,7 @@ public function processLogCallback($type, $buffer): void
129
119
fwrite (STDERR , $ buffer );
130
120
} else {
131
121
fwrite (STDOUT , $ buffer );
132
- $ this ->log ($ buffer );
133
- }
134
- }
135
-
136
- private function log (string $ log , bool $ master_log = false ): void
137
- {
138
- if ($ master_log ) {
139
- $ log = "\n[static-php-cli]> " . $ log . "\n\n" ;
140
- } else {
141
- $ log = preg_replace ('/\x1b\[[0-9;]*m/ ' , '' , $ log );
142
122
}
143
- file_put_contents ('craft.log ' , $ log , FILE_APPEND );
144
123
}
145
124
146
125
private function runCommand (string $ cmd , ...$ args ): int
@@ -149,11 +128,11 @@ private function runCommand(string $cmd, ...$args): int
149
128
if ($ this ->getOption ('debug ' )) {
150
129
array_unshift ($ args , '--debug ' );
151
130
}
131
+ array_unshift ($ args , '--preserve-log ' );
152
132
$ prefix = PHP_SAPI === 'cli ' ? [PHP_BINARY , $ argv [0 ]] : [$ argv [0 ]];
153
133
154
134
$ env = getenv ();
155
135
$ process = new Process ([...$ prefix , $ cmd , '--no-motd ' , ...$ args ], env: $ env , timeout: null );
156
- $ this ->log ("Running: {$ process ->getCommandLine ()}" , true );
157
136
158
137
if (PHP_OS_FAMILY === 'Windows ' ) {
159
138
sapi_windows_set_ctrl_handler (function () use ($ process ) {
@@ -163,6 +142,7 @@ private function runCommand(string $cmd, ...$args): int
163
142
});
164
143
} elseif (extension_loaded ('pcntl ' )) {
165
144
pcntl_signal (SIGINT , function () use ($ process ) {
145
+ /* @noinspection PhpComposerExtensionStubsInspection */
166
146
$ process ->signal (SIGINT );
167
147
});
168
148
} else {
0 commit comments