Skip to content

Commit

Permalink
Merge pull request #93 from Dealerdirect/feature/send-exit-code
Browse files Browse the repository at this point in the history
Send an exit code when the script terminates
  • Loading branch information
Potherca committed Jan 17, 2020
2 parents 2663c72 + 687bfb6 commit bb64a27
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Plugin.php
Expand Up @@ -164,6 +164,7 @@ public function onDependenciesChangedEvent()
{
$io = $this->io;
$isVerbose = $io->isVerbose();
$exitCode = 0;

if ($isVerbose) {
$io->write(sprintf('<info>%s</info>', self::MESSAGE_RUNNING_INSTALLER));
Expand All @@ -175,13 +176,18 @@ public function onDependenciesChangedEvent()
$installPathUpdated = $this->updateInstalledPaths();

if ($installPathCleaned === true || $installPathUpdated === true) {
$this->saveInstalledPaths();
$exitCode = $this->saveInstalledPaths();
} elseif ($isVerbose) {
$io->write(sprintf('<info>%s</info>', self::MESSAGE_NOTHING_TO_INSTALL));
}
} elseif ($isVerbose) {
$io->write(sprintf('<info>%s</info>', self::MESSAGE_NOT_INSTALLED));
} else {
$exitCode = 1;
if ($isVerbose) {
$io->write(sprintf('<info>%s</info>', self::MESSAGE_NOT_INSTALLED));
}
}

exit($exitCode);
}

/**
Expand Down Expand Up @@ -218,6 +224,8 @@ private function loadInstalledPaths()
* @throws LogicException
* @throws ProcessFailedException
* @throws RuntimeException
*
* @return int Exit code. 0 for success, 1 or higher for failure.
*/
private function saveInstalledPaths()
{
Expand Down Expand Up @@ -276,6 +284,8 @@ private function saveInstalledPaths()
if ($this->io->isVerbose() && !empty($configResult)) {
$this->io->write(sprintf('<info>%s</info>', $configResult));
}

return $exitCode;
}

/**
Expand Down

0 comments on commit bb64a27

Please sign in to comment.