From 90417c6ffe35c6ba479121a60085f0cfd35c6d1e Mon Sep 17 00:00:00 2001 From: Pierre-Denis Vanduynslager Date: Fri, 6 Oct 2017 00:23:10 -0400 Subject: [PATCH] fix: Exit with 1 if unexpected error happens --- bin/semantic-release.js | 4 +++- test/integration.test.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/bin/semantic-release.js b/bin/semantic-release.js index 95d9c323..60bad2d2 100755 --- a/bin/semantic-release.js +++ b/bin/semantic-release.js @@ -23,4 +23,6 @@ npx is bundled with npm >= 5.4, or available via npm. More info: npm.im/npx` } // node 8+ from this point on -require('../src')(); +require('../src')().catch(() => { + process.exit(1); +}); diff --git a/test/integration.test.js b/test/integration.test.js index 6831dbfa..6d8b5e71 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -207,3 +207,26 @@ test.serial('Release versions from a packed git repository, using tags to determ t.is(version, '1.0.1'); t.log(`+ released ${version}`); }); + +test.serial('Exit with 1 in a plugin is not found', async t => { + // Environment variables used with cli + const env = { + CI: true, + npm_config_registry: uri, + GH_TOKEN: 'github_token', + NPM_OLD_TOKEN: 'aW50ZWdyYXRpb246c3VjaHNlY3VyZQ==', + NPM_EMAIL: 'integration@test.com', + }; + // Create a git repository, set the current working directory at the root of the repo + t.log('Create git repository'); + await gitRepo(); + await writeJson('./package.json', { + name: 'test-module-3', + version: '0.0.0-dev', + repository: {url: 'git+https://github.com/semantic-release/test-module-4'}, + release: {analyzeCommits: 'non-existing-path'}, + }); + + const {code} = await t.throws(execa(require.resolve('../bin/semantic-release'), ['pre'], {env})); + t.is(code, 1); +});