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

Normalize ci: false into noCi: true after configs get merged #1732

Merged
merged 1 commit into from Jan 13, 2021
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions lib/get-config.js
Expand Up @@ -27,9 +27,6 @@ module.exports = async (context, cliOptions) => {

// Merge config file options and CLI/API options
let options = {...config, ...cliOptions};
if (options.ci === false) {
options.noCi = true;
}

const pluginsPath = {};
let extendPaths;
Expand Down Expand Up @@ -87,6 +84,10 @@ module.exports = async (context, cliOptions) => {
...(options.branches ? {branches: castArray(options.branches)} : {}),
};

if (options.ci === false) {
options.noCi = true;
}

debug('options values: %O', options);

return {options, plugins: await plugins({...context, options}, pluginsPath)};
Expand Down
21 changes: 19 additions & 2 deletions test/get-config.test.js
Expand Up @@ -505,14 +505,31 @@ test('Allow to unset properties defined in shareable config with "undefined"', a
test('Throw an Error if one of the shareable config cannot be found', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd} = await gitRepo();
const pkhOptions = {extends: ['./shareable1.json', 'non-existing-path']};
const pkgOptions = {extends: ['./shareable1.json', 'non-existing-path']};
const options1 = {analyzeCommits: 'analyzeCommits'};
// Create package.json and shareable.json in repository root
await outputJson(path.resolve(cwd, 'package.json'), {release: pkhOptions});
await outputJson(path.resolve(cwd, 'package.json'), {release: pkgOptions});
await outputJson(path.resolve(cwd, 'shareable1.json'), options1);

await t.throwsAsync(t.context.getConfig({cwd}), {
message: /Cannot find module 'non-existing-path'/,
code: 'MODULE_NOT_FOUND',
});
});

test('Convert "ci" option to "noCi" when set from extended config', async (t) => {
// Create a git repository, set the current working directory at the root of the repo
const {cwd} = await gitRepo();
const pkgOptions = {extends: './no-ci.json'};
const options = {
ci: false,
};
// Create package.json and shareable.json in repository root
await outputJson(path.resolve(cwd, 'package.json'), {release: pkgOptions});
await outputJson(path.resolve(cwd, 'no-ci.json'), options);

const {options: result} = await t.context.getConfig({cwd});

t.is(result.ci, false);
t.is(result.noCi, true);
});