diff --git a/compiler/Compiler.php b/compiler/Compiler.php index 1c8e286..7392cec 100644 --- a/compiler/Compiler.php +++ b/compiler/Compiler.php @@ -125,11 +125,11 @@ final class Compiler */ private function getCodeViaFilePath(string $filePath): string { - echo "Packing `{$filePath}`... "; + // echo "Packing `{$filePath}`... "; $code = file_get_contents($filePath); if (false === $code) { - echo "FAILED\n"; + echo "[FAILED] {$filePath}\n"; return ''; } @@ -140,7 +140,7 @@ final class Compiler // 💡 Opt: Safely remove leading scriptFilePath)) { + if ( !is_file($this->scriptFilePath)) { throw new InvalidArgumentException("[ScriptGeneration] Source file not found: {$this->scriptFilePath}"); } // 验证目标模板文件是否存在 / Validate if the destination file exists - if ( ! is_file($this->distFilePath)) { + if ( !is_file($this->distFilePath)) { throw new InvalidArgumentException("[ScriptGeneration] Destination file not found: {$this->distFilePath}"); } @@ -47,7 +47,7 @@ final class ScriptGeneration $this->setScript($scriptContent); - echo "[ScriptGeneration] Script content written successfully.\n"; + echo "[ScriptGeneration] Script content has been written successfully.\n"; } /** @@ -81,7 +81,7 @@ final class ScriptGeneration // 检查是否存在占位符(可选优化:防止无效替换) // Check if the placeholder exists (Optional optimization: prevent redundant writes) - if ( ! str_contains($distContent, '{{X_SCRIPT}}')) { + if ( !str_contains($distContent, '{{X_SCRIPT}}')) { throw new RuntimeException('[ScriptGeneration] Placeholder {{X_SCRIPT}} not found in destination file.'); } diff --git a/compiler/StyleGeneration.php b/compiler/StyleGeneration.php index c6795ba..60be1cc 100644 --- a/compiler/StyleGeneration.php +++ b/compiler/StyleGeneration.php @@ -30,13 +30,13 @@ final class StyleGeneration { // 校验源样式文件是否存在 // Validate if the source style file exists. - if ( ! is_file($this->styleFilePath)) { + if ( !is_file($this->styleFilePath)) { throw new RuntimeException("[StyleGeneration] File not found: {$this->styleFilePath}"); } // 校验目标文件是否存在 // Validate if the target dist file exists. - if ( ! is_file($this->distFilePath)) { + if ( !is_file($this->distFilePath)) { throw new RuntimeException("[StyleGeneration] File not found: {$this->distFilePath}"); } @@ -45,7 +45,7 @@ final class StyleGeneration // 执行替换并写入文件 // Perform replacement and write to file. if ($this->setStyle($styleContent)) { - echo "[StyleGeneration] Script content wrote successfully.\n"; + echo "[StyleGeneration] Script content has been written successfully.\n"; } else { throw new RuntimeException('[StyleGeneration] Error: Cannot write script content to dist.'); }