Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions bin/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ args
.option('pre', 'Mark the release as prerelease')
.option('overwrite', 'If the release already exists, replace it')
.option('publish', 'Instead of creating a draft, publish the release')
.option(['H', 'hook'], 'Specify a custom file to pipe releases through');
.option(['H', 'hook'], 'Specify a custom file to pipe releases through')
.option('show-url', 'Show the release URL instead of opening it in the browser');

const flags = args.parse(process.argv);

Expand Down Expand Up @@ -83,7 +84,8 @@ const createRelease = async (tag, changelog, exists) => {

const methodPrefix = exists ? 'edit' : 'create';
const method = `${methodPrefix}Release`;
const {pre, publish} = flags;
const {pre, publish, showUrl} = flags;


const body = {
owner: repoDetails.user,
Expand Down Expand Up @@ -120,11 +122,12 @@ const createRelease = async (tag, changelog, exists) => {
// Wait for the GitHub UI to render the release
await sleep(500);

if (releaseURL) {
if (showUrl && releaseURL) {
console.log(`\n${chalk.bold('Done!')} ${releaseURL}`);
} else if (releaseURL) {
open(releaseURL);
console.log(`\n${chalk.bold('Done!')} Opening release in browser...`);
}

console.log(`\n${chalk.bold('Done!')} Opening release in browser...`);
};

const orderCommits = async (commits, tags, exists) => {
Expand Down Expand Up @@ -354,11 +357,11 @@ const checkReleaseStatus = async () => {

const releaseURL = getReleaseURL(existingRelease);

if (releaseURL) {
if (!flags.showUrl && releaseURL) {
open(releaseURL);
}

const alreadyThere = 'Release already exists. Opening in browser...';
const alreadyThere = `Release already exists${flags.showUrl ? `: ${releaseURL}` : '. Opening in browser...'}`;
console.error(`${chalk.red('Error!')} ${alreadyThere}`);

process.exit(1);
Expand Down