diff --git a/src/Builder.php b/src/Builder.php index 4206cd5..35fb1bb 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -81,7 +81,7 @@ public function saveFiles() $this->writeConfig('__addition', $this->addition); } - public static function rebuild($outputDir) + public static function rebuild($outputDir = null) { $builder = new self([], $outputDir); $builder->loadFiles(); @@ -123,7 +123,7 @@ public function buildConfigs($files = null) } $this->buildConfig($name, $configs); } - file_put_contents($this->getOutputPath('__rebuild'), file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '__rebuild.php')); + static::putFile($this->getOutputPath('__rebuild'), file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '__rebuild.php')); } /** @@ -186,10 +186,12 @@ public static function writeFile($path, array $data) */ protected static function putFile($path, $content) { - if (file_exists($path) && $content = file_get_contents($path)) { + if (file_exists($path) && $content === file_get_contents($path)) { return; } - file_put_contents($path, $content); + if (file_put_contents($path, $content) === FALSE) { + throw new FailedWriteException("Failed write file $path"); + } } /** diff --git a/src/FailedWriteException.php b/src/FailedWriteException.php new file mode 100644 index 0000000..e0738bd --- /dev/null +++ b/src/FailedWriteException.php @@ -0,0 +1,20 @@ + + */ +class FailedWriteException extends \Exception +{ +}