Skip to content

Commit

Permalink
fix() support --pre when publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Aug 29, 2018
1 parent 7d2a634 commit f8a5ff1
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions scripts/publish.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
const { promisify } = require('util');
const exec = promisify(require('child_process').exec);

const cmdArguments = process.argv.slice(2);
const semverType = cmdArguments[0];
const args = process.argv.slice(2);
const semverType = args[0];

const prerelease = args.indexOf('--pre') >= 0;
const prereleaseType = prerelease ? args[args.indexOf('--pre') + 1] : null;


console.log(semverType);

if (!semverType || !semverType.match(/^(major|minor|patch|premajor|preminor|prepatch|prerelease)$/)) {
console.log(`Usage: major|minor|patch|premajor|preminor|prepatch|prerelease`);
if (!semverType || !semverType.match(/^(major|minor|patch)$/)) {
console.log(`Usage: major|minor|patch`);
process.exit(1);
}
if (prerelease && !prereleaseType.match(/^(alpha|beta|rc)$/)) {
console.log(`Usage: major|minor|patch --pre [alpha|beta|rc]`);
process.exit(1);
}


async function run(command) {
Expand All @@ -22,8 +30,9 @@ async function run(command) {
}

async function main() {
const version = `${semverType} ${prerelease ? '--preid=' + prereleaseType : ''}`;
await run(`npm run verify`);
await run(`npm version ${semverType}`);
await run(`npm version ${version}`);
await run(`git push`);
await run(`git push --tags`);
await run(`npm publish`);
Expand Down

0 comments on commit f8a5ff1

Please sign in to comment.