Skip to content

Commit

Permalink
Throw a more descriptive exception when the binary was not created
Browse files Browse the repository at this point in the history
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 <development@voke.dev>
  • Loading branch information
caendesilva and owenvoke committed Dec 5, 2023
1 parent 517dddb commit d3bb835
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Commands/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d3bb835

Please sign in to comment.