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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
Potherca marked this conversation as resolved.
Show resolved Hide resolved
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