Skip to content

Commit

Permalink
fix: throw on missing info during release prep (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Nov 5, 2020
1 parent 74a6b69 commit 223d075
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/prepare_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class ReleasePreparation {
this.date = '';
this.config = getMergedConfig(this.dir);

// Ensure the preparer has set an upstream and username.
if (this.warnForMissing()) {
cli.error('Failed to begin the release preparation process.');
return;
}

// Allow passing optional new version.
if (argv.newVersion) {
const newVersion = semver.clean(argv.newVersion);
Expand Down Expand Up @@ -224,6 +230,33 @@ class ReleasePreparation {
return this.config.username;
}

warnForMissing() {
const { cli, upstream, username } = this;

const missing = !username || !upstream;
if (!upstream) {
cli.warn('You have not told git-node the remote you want to sync with.');
cli.separator();
cli.info(
'For example, if your remote pointing to nodejs/node is' +
' `remote-upstream`, you can run:\n\n' +
' $ ncu-config set upstream remote-upstream');
cli.separator();
cli.setExitCode(1);
}
if (!username) {
cli.warn('You have not told git-node your username.');
cli.separator();
cli.info(
'To fix this, you can run: ' +
' $ ncu-config set username <your_username>');
cli.separator();
cli.setExitCode(1);
}

return missing;
}

calculateNewVersion() {
let newVersion;

Expand Down

0 comments on commit 223d075

Please sign in to comment.