Skip to content

Commit 06c7226

Browse files
aseureEunjae LeeHaroenvshipjs
authored
feat: understands --config <FILE> option in conventionalChangelogArgs (#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>
1 parent f8a1ddb commit 06c7226

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const path = require('path');
2+
import { prepareParams } from '../updateChangelog';
3+
import { parseArgs } from '../../../util';
4+
import tempWrite from 'temp-write';
5+
6+
describe('prepareParams', () => {
7+
it('loads configuration from --config option', () => {
8+
parseArgs.mockImplementation(jest.requireActual('../../../util').parseArgs);
9+
const config = {
10+
writerOpts: {
11+
headerPartial: '## {{version}}',
12+
},
13+
};
14+
const configString = `module.exports = ${JSON.stringify(config)};`;
15+
const configPath = tempWrite.sync(configString);
16+
const configDir = path.basename(path.dirname(configPath));
17+
18+
const { args } = prepareParams({
19+
dir: configDir,
20+
conventionalChangelogArgs: `-i CHANGELOG.md -s --config ${configPath}`,
21+
revisionRange: '1.0.0..1.0.1',
22+
reject: () => {},
23+
});
24+
expect(args.config).toEqual(config);
25+
});
26+
});

packages/shipjs/src/step/prepare/updateChangelog.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const argSpec = {
7878
'-t': '--tag-prefix',
7979
};
8080

81-
function prepareParams({
81+
export function prepareParams({
8282
dir,
8383
conventionalChangelogArgs,
8484
releaseCount,
@@ -118,6 +118,9 @@ function prepareParams({
118118
}
119119
const templateContext =
120120
args.context && require(path.resolve(dir, args.context));
121+
if (args.config) {
122+
args.config = require(path.resolve(dir, args.config));
123+
}
121124
return { args, gitRawCommitsOpts, templateContext };
122125
}
123126

0 commit comments

Comments
 (0)