Skip to content

Commit

Permalink
Merge pull request #116 from liferay/wincent/easier-dry-run
Browse files Browse the repository at this point in the history
feat(changelog-generator): make --version optional when --dry-run is on
  • Loading branch information
wincent authored Oct 5, 2020
2 parents 4ece019 + e9ad08b commit 2ba311d
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions projects/npm-tools/packages/changelog-generator/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ async function normalizeVersion(version, {force}, versionTagPrefix) {
return version;
}

function parseArgs(args) {
async function parseArgs(args) {
const options = {
dryRun: false,
outfile: './CHANGELOG.md',
Expand Down Expand Up @@ -595,9 +595,19 @@ function parseArgs(args) {
});

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

return null;
const version = `${prefix}0.0.0-placeholder`;

info(`Using phony version ${version} during --dry-run`);

options.version = version;
} else {
error('Missing required option: --version; see --help for usage');

return null;
}
}

return options;
Expand Down Expand Up @@ -692,12 +702,6 @@ async function getVersionTagPrefix() {
}

async function main(_node, _script, ...args) {
const options = parseArgs(args);
if (!options) {
process.exit(1);
}
const {outfile, to, updateTags} = options;

printBanner(`
changelog.js
============
Expand All @@ -706,6 +710,14 @@ async function main(_node, _script, ...args) {
for duty!
`);

const options = await parseArgs(args);

if (!options) {
process.exit(1);
}

const {outfile, to, updateTags} = options;

if (updateTags) {
try {
info('Fetching remote tags: run with --no-update-tags to skip');
Expand Down

0 comments on commit 2ba311d

Please sign in to comment.