Skip to content

Commit

Permalink
Send an exit code when the script terminates
Browse files Browse the repository at this point in the history
This fixes the issue identified in #80 (comment) where even when the setting of `installed_paths` failed, the plugin would exit with exit code `0`.
  • Loading branch information
jrfnl committed Dec 9, 2019
1 parent 6fa8d1e commit 5afbea6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Plugin.php
Expand Up @@ -163,6 +163,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 @@ -174,13 +175,16 @@ 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));
$exitCode = 1;
}

exit($exitCode);
}

/**
Expand Down Expand Up @@ -217,6 +221,8 @@ private function loadInstalledPaths()
* @throws LogicException
* @throws ProcessFailedException
* @throws RuntimeException
*
* @return int Exit code of the PHPCS command.
*/
private function saveInstalledPaths()
{
Expand Down Expand Up @@ -252,6 +258,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 5afbea6

Please sign in to comment.