Skip to content

Commit

Permalink
feat: understands --config <FILE> option in `conventionalChangelogA…
Browse files Browse the repository at this point in the history
…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 06c7226
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
26 changes: 26 additions & 0 deletions packages/shipjs/src/step/prepare/__tests__/updateChangelog.spec.js
@@ -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);
});
});
5 changes: 4 additions & 1 deletion packages/shipjs/src/step/prepare/updateChangelog.js
Expand Up @@ -78,7 +78,7 @@ const argSpec = {
'-t': '--tag-prefix',
};

function prepareParams({
export function prepareParams({
dir,
conventionalChangelogArgs,
releaseCount,
Expand Down Expand Up @@ -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 };
}

Expand Down

0 comments on commit 06c7226

Please sign in to comment.