Skip to content

Commit 90417c6

Browse files
committed
fix: Exit with 1 if unexpected error happens
1 parent 85dd69b commit 90417c6

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

bin/semantic-release.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ npx is bundled with npm >= 5.4, or available via npm. More info: npm.im/npx`
2323
}
2424

2525
// node 8+ from this point on
26-
require('../src')();
26+
require('../src')().catch(() => {
27+
process.exit(1);
28+
});

test/integration.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,26 @@ test.serial('Release versions from a packed git repository, using tags to determ
207207
t.is(version, '1.0.1');
208208
t.log(`+ released ${version}`);
209209
});
210+
211+
test.serial('Exit with 1 in a plugin is not found', async t => {
212+
// Environment variables used with cli
213+
const env = {
214+
CI: true,
215+
npm_config_registry: uri,
216+
GH_TOKEN: 'github_token',
217+
NPM_OLD_TOKEN: 'aW50ZWdyYXRpb246c3VjaHNlY3VyZQ==',
218+
NPM_EMAIL: '[email protected]',
219+
};
220+
// Create a git repository, set the current working directory at the root of the repo
221+
t.log('Create git repository');
222+
await gitRepo();
223+
await writeJson('./package.json', {
224+
name: 'test-module-3',
225+
version: '0.0.0-dev',
226+
repository: {url: 'git+https://github.com/semantic-release/test-module-4'},
227+
release: {analyzeCommits: 'non-existing-path'},
228+
});
229+
230+
const {code} = await t.throws(execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
231+
t.is(code, 1);
232+
});

0 commit comments

Comments
 (0)