Skip to content

Commit 862ec4c

Browse files
committedDec 11, 2018
fix: allow to set ci option via API and config file
1 parent 6b110b6 commit 862ec4c

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed
 

‎cli.js

-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ Usage:
4747
return 0;
4848
}
4949

50-
// Set the `noCi` options as yargs sets the `ci` options instead (because arg starts with `--no`)
51-
if (opts.ci === false) {
52-
opts.noCi = true;
53-
}
54-
5550
if (opts.debug) {
5651
// Debug must be enabled before other requires in order to work
5752
require('debug').enable('semantic-release:*');

‎lib/get-config.js

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ module.exports = async (context, opts) => {
2727

2828
// Merge config file options and CLI/API options
2929
let options = {...config, ...opts};
30+
if (options.ci === false) {
31+
options.noCi = true;
32+
}
3033
const pluginsPath = {};
3134
let extendPaths;
3235
({extends: extendPaths, ...options} = options);

‎test/cli.test.js

-12
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,6 @@ test.serial('Do not set properties in option for which arg is not in command lin
163163
t.false('e' in run.args[0][0]);
164164
});
165165

166-
test.serial('Set "noCi" options to "true" with "--no-ci"', async t => {
167-
const run = stub().resolves(true);
168-
const argv = ['', '', '--no-ci'];
169-
const cli = requireNoCache('../cli', {'.': run, process: {...process, argv}});
170-
171-
const exitCode = await cli();
172-
173-
t.is(run.args[0][0].noCi, true);
174-
175-
t.is(exitCode, 0);
176-
});
177-
178166
test.serial('Display help', async t => {
179167
const run = stub().resolves(true);
180168
const argv = ['', '', '--help'];

‎test/get-config.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ test('Default values, reading repositoryUrl (http url) from package.json if not
6767
t.is(result.tagFormat, `v\${version}`);
6868
});
6969

70+
test('Convert "ci" option to "noCi"', async t => {
71+
const pkg = {repository: 'https://host.null/owner/module.git', release: {ci: false}};
72+
// Create a git repository, set the current working directory at the root of the repo
73+
const {cwd} = await gitRepo();
74+
// Create package.json in repository root
75+
await outputJson(path.resolve(cwd, 'package.json'), pkg);
76+
77+
const {options: result} = await t.context.getConfig({cwd});
78+
79+
t.is(result.noCi, true);
80+
});
81+
7082
test('Read options from package.json', async t => {
7183
// Create a git repository, set the current working directory at the root of the repo
7284
const {cwd} = await gitRepo();

0 commit comments

Comments
 (0)
Please sign in to comment.