Skip to content

Commit 08fa49b

Browse files
committed
Remove craft.log
1 parent 333b776 commit 08fa49b

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

src/SPC/command/CraftCommand.php

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,11 @@ public function handle(): int
5454
$shared_extensions = implode(',', $craft['shared-extensions'] ?? []);
5555
$libs = implode(',', $craft['libs']);
5656

57-
// init log
58-
if (file_exists(WORKING_DIR . '/craft.log')) {
59-
unlink(WORKING_DIR . '/craft.log');
60-
}
61-
6257
// craft doctor
6358
if ($craft['craft-options']['doctor']) {
6459
$retcode = $this->runCommand('doctor', '--auto-fix');
6560
if ($retcode !== 0) {
6661
$this->output->writeln('<error>craft doctor failed</error>');
67-
$this->log("craft doctor failed with code: {$retcode}", true);
6862
return static::FAILURE;
6963
}
7064
}
@@ -73,7 +67,6 @@ public function handle(): int
7367
$retcode = $this->runCommand('install-pkg', 'go-xcaddy');
7468
if ($retcode !== 0) {
7569
$this->output->writeln('<error>craft go-xcaddy failed</error>');
76-
$this->log("craft: spc install-pkg go-xcaddy failed with code: {$retcode}", true);
7770
return static::FAILURE;
7871
}
7972
}
@@ -82,7 +75,6 @@ public function handle(): int
8275
$retcode = $this->runCommand('install-pkg', 'zig');
8376
if ($retcode !== 0) {
8477
$this->output->writeln('<error>craft zig failed</error>');
85-
$this->log("craft: spc install-pkg zig failed with code: {$retcode}", true);
8678
return static::FAILURE;
8779
}
8880
}
@@ -103,7 +95,6 @@ public function handle(): int
10395
$retcode = $this->runCommand('download', ...$args);
10496
if ($retcode !== 0) {
10597
$this->output->writeln('<error>craft download failed</error>');
106-
$this->log('craft download failed with code: ' . $retcode, true);
10798
return static::FAILURE;
10899
}
109100
}
@@ -115,7 +106,6 @@ public function handle(): int
115106
$retcode = $this->runCommand('build', ...$args);
116107
if ($retcode !== 0) {
117108
$this->output->writeln('<error>craft build failed</error>');
118-
$this->log('craft build failed with code: ' . $retcode, true);
119109
return static::FAILURE;
120110
}
121111
}
@@ -129,18 +119,7 @@ public function processLogCallback($type, $buffer): void
129119
fwrite(STDERR, $buffer);
130120
} else {
131121
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);
142122
}
143-
file_put_contents('craft.log', $log, FILE_APPEND);
144123
}
145124

146125
private function runCommand(string $cmd, ...$args): int
@@ -149,11 +128,11 @@ private function runCommand(string $cmd, ...$args): int
149128
if ($this->getOption('debug')) {
150129
array_unshift($args, '--debug');
151130
}
131+
array_unshift($args, '--preserve-log');
152132
$prefix = PHP_SAPI === 'cli' ? [PHP_BINARY, $argv[0]] : [$argv[0]];
153133

154134
$env = getenv();
155135
$process = new Process([...$prefix, $cmd, '--no-motd', ...$args], env: $env, timeout: null);
156-
$this->log("Running: {$process->getCommandLine()}", true);
157136

158137
if (PHP_OS_FAMILY === 'Windows') {
159138
sapi_windows_set_ctrl_handler(function () use ($process) {
@@ -163,6 +142,7 @@ private function runCommand(string $cmd, ...$args): int
163142
});
164143
} elseif (extension_loaded('pcntl')) {
165144
pcntl_signal(SIGINT, function () use ($process) {
145+
/* @noinspection PhpComposerExtensionStubsInspection */
166146
$process->signal(SIGINT);
167147
});
168148
} else {

0 commit comments

Comments
 (0)