Skip to content

Commit

Permalink
feat: understands --config <FILE> option in `conventionalChangelogA…
Browse files Browse the repository at this point in the history
…rgs`
  • Loading branch information
aseure committed Sep 23, 2020
1 parent f8a1ddb commit fdaa4df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/shipjs/src/step/prepare/__tests__/updateChangelog.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require('path');
import prepareParams from '../updateChangelog';
import tempWrite from 'temp-write';

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

const { args } = prepareParams({
dir: configDir,
conventionalChangelogArgs: `--config ${configPath}`,
revisionRange: '1.0.0..1.0.1',
reject: () => {},
});
expect(args.config).toMatch(config);
});
});
3 changes: 3 additions & 0 deletions packages/shipjs/src/step/prepare/updateChangelog.js
Original file line number Diff line number Diff line change
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 fdaa4df

Please sign in to comment.