Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send an exit code when the script terminates #93

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
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,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;
Potherca marked this conversation as resolved.
Show resolved Hide resolved
}

exit($exitCode);
}

/**
Expand Down Expand Up @@ -218,6 +222,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 +282,8 @@ private function saveInstalledPaths()
if ($this->io->isVerbose() && !empty($configResult)) {
$this->io->write(sprintf('<info>%s</info>', $configResult));
}

return $exitCode;
}

/**
Expand Down