Skip to content

Commit 2ba311d

Browse files
authored
Merge pull request #116 from liferay/wincent/easier-dry-run
feat(changelog-generator): make --version optional when --dry-run is on
2 parents 4ece019 + e9ad08b commit 2ba311d

File tree

1 file changed

+21
-9
lines changed
  • projects/npm-tools/packages/changelog-generator/src

1 file changed

+21
-9
lines changed

projects/npm-tools/packages/changelog-generator/src/index.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ async function normalizeVersion(version, {force}, versionTagPrefix) {
510510
return version;
511511
}
512512

513-
function parseArgs(args) {
513+
async function parseArgs(args) {
514514
const options = {
515515
dryRun: false,
516516
outfile: './CHANGELOG.md',
@@ -595,9 +595,19 @@ function parseArgs(args) {
595595
});
596596

597597
if (!options.version) {
598-
error('Missing required option: --version; see --help for usage');
598+
if (options.dryRun) {
599+
const prefix = await getVersionTagPrefix();
599600

600-
return null;
601+
const version = `${prefix}0.0.0-placeholder`;
602+
603+
info(`Using phony version ${version} during --dry-run`);
604+
605+
options.version = version;
606+
} else {
607+
error('Missing required option: --version; see --help for usage');
608+
609+
return null;
610+
}
601611
}
602612

603613
return options;
@@ -692,12 +702,6 @@ async function getVersionTagPrefix() {
692702
}
693703

694704
async function main(_node, _script, ...args) {
695-
const options = parseArgs(args);
696-
if (!options) {
697-
process.exit(1);
698-
}
699-
const {outfile, to, updateTags} = options;
700-
701705
printBanner(`
702706
changelog.js
703707
============
@@ -706,6 +710,14 @@ async function main(_node, _script, ...args) {
706710
for duty!
707711
`);
708712

713+
const options = await parseArgs(args);
714+
715+
if (!options) {
716+
process.exit(1);
717+
}
718+
719+
const {outfile, to, updateTags} = options;
720+
709721
if (updateTags) {
710722
try {
711723
info('Fetching remote tags: run with --no-update-tags to skip');

0 commit comments

Comments
 (0)