Skip to content
Permalink
Browse files

feat: understands `--config <FILE>` option in `conventionalChangelogA…

…rgs` (#927)

* feat: understands `--config <FILE>` option in `conventionalChangelogArgs`

* Update packages/shipjs/src/step/prepare/__tests__/updateChangelog.spec.js

Co-authored-by: Haroen Viaene <hello@haroen.me>

* fix test case

Co-authored-by: Eunjae Lee <eunjae.lee@algolia.com>
Co-authored-by: Haroen Viaene <hello@haroen.me>
Co-authored-by: shipjs <shipjs@test.com>
  • Loading branch information
4 people committed Sep 25, 2020
1 parent f8a1ddb commit 06c7226fa66185edd23f6626b6a2b8b7df1d93b6
@@ -0,0 +1,26 @@
const path = require('path');
import { prepareParams } from '../updateChangelog';
import { parseArgs } from '../../../util';
import tempWrite from 'temp-write';

describe('prepareParams', () => {
it('loads configuration from --config option', () => {
parseArgs.mockImplementation(jest.requireActual('../../../util').parseArgs);
const config = {
writerOpts: {
headerPartial: '## {{version}}',
},
};
const configString = `module.exports = ${JSON.stringify(config)};`;
const configPath = tempWrite.sync(configString);
const configDir = path.basename(path.dirname(configPath));

const { args } = prepareParams({
dir: configDir,
conventionalChangelogArgs: `-i CHANGELOG.md -s --config ${configPath}`,
revisionRange: '1.0.0..1.0.1',
reject: () => {},
});
expect(args.config).toEqual(config);
});
});
@@ -78,7 +78,7 @@ const argSpec = {
'-t': '--tag-prefix',
};

function prepareParams({
export function prepareParams({
dir,
conventionalChangelogArgs,
releaseCount,
@@ -118,6 +118,9 @@ function prepareParams({
}
const templateContext =
args.context && require(path.resolve(dir, args.context));
if (args.config) {
args.config = require(path.resolve(dir, args.config));
}
return { args, gitRawCommitsOpts, templateContext };
}

0 comments on commit 06c7226

Please sign in to comment.
You can’t perform that action at this time.