diff --git a/lib/cli.js b/lib/cli.js index 5589e5b4..7e8611b8 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -164,6 +164,10 @@ class CLI { this.log(prefix + chalk.bold(`${error} ${obj}`)); } } + + setExitCode(statusCode) { + process.exitCode = statusCode; + } }; CLI.SPINNER_STATUS = SPINNER_STATUS; diff --git a/lib/landing_session.js b/lib/landing_session.js index 601640ec..0b7e191b 100644 --- a/lib/landing_session.js +++ b/lib/landing_session.js @@ -53,6 +53,7 @@ class LandingSession extends Session { await this.tryResetBranch(); } cli.ok(`Aborted \`git node land\` session in ${this.ncuDir}`); + cli.setExitCode(1); } async downloadAndPatch() { diff --git a/lib/session.js b/lib/session.js index 02d07c1a..4e107d84 100644 --- a/lib/session.js +++ b/lib/session.js @@ -35,6 +35,7 @@ class Session { if (!new RegExp(`${owner}/${repo}(?:.git)?$`).test(upstreamHref)) { cli.warn('Remote repository URL does not point to the expected ' + `repository ${owner}/${repo}`); + cli.setExitCode(1); } } @@ -343,6 +344,7 @@ class Session { '`master` branch, you can run:\n\n' + ' $ ncu-config set branch master'); cli.separator(); + cli.setExitCode(1); } if (!upstream) { cli.warn('You have not told git-node the remote you want to sync with.'); @@ -352,6 +354,7 @@ class Session { ' `remote-upstream`, you can run:\n\n' + ' $ ncu-config set upstream remote-upstream'); cli.separator(); + cli.setExitCode(1); } return missing; } @@ -363,6 +366,7 @@ class Session { cli.warn( 'You are in detached HEAD state. Please run git-node on a valid ' + 'branch'); + cli.setExitCode(1); return true; } if (rev === branch) { @@ -377,6 +381,7 @@ class Session { ' reconfigure the target branch with:\n\n' + ` $ ncu-config set branch ${rev}`); cli.separator(); + cli.setExitCode(1); return true; // TODO warn if backporting onto master branch }