From d3bb8356e73ed0ab689970c607643b06baac2b80 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 1 Dec 2023 18:52:45 +0100 Subject: [PATCH] Throw a more descriptive exception when the binary was not created When the build command fails and a binary was not created, this results in an error like `rename(app.phar, builds/app): the system cannot find the file specified `. This is not very descriptive to the actual issue, so this PR adds a check to thrown an exception if the file was not created. This will make debugging easier. Co-Authored-By: Owen Voke --- src/Commands/BuildCommand.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Commands/BuildCommand.php b/src/Commands/BuildCommand.php index 7443367c..c8ebae02 100644 --- a/src/Commands/BuildCommand.php +++ b/src/Commands/BuildCommand.php @@ -21,6 +21,7 @@ use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\Process; +use RuntimeException; use Throwable; use function Laravel\Prompts\text; @@ -162,7 +163,13 @@ private function compile(string $name): BuildCommand $this->output->newLine(); - File::move($this->app->basePath($this->getBinary()).'.phar', $this->app->buildsPath($name)); + $pharPath = $this->app->basePath($this->getBinary()) . '.phar'; + + if (! File::exists($pharPath)) { + throw new RuntimeException('Failed to compile the application.'); + } + + File::move($pharPath, $this->app->buildsPath($name)); return $this; }