Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
janschoenherr committed Oct 8, 2018
1 parent 21a3941 commit 89c9807
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions build/publishDev.js
@@ -1,26 +1,25 @@

/* eslint-env node */
const path = require('path');
const {execSync} = require('child_process');
const jsonData = require('../package.json');

//default exec options
// default exec options
const execOpts = {cwd: path.resolve(__dirname + '/..'), encoding: 'utf8'};

//get clean version string
// get clean version string
let [, version] = /(\d+\.\d+\.\d+)/.exec(jsonData.version);

//if this is a regular version, e.g. no 'beta', 'alpha' or 'rc', do increment the version by 1
// if this is a regular version, e.g. no 'beta', 'alpha' or 'rc', do increment the version by 1
if (!['-alpha', '-beta', '-rc'].some(qualifier => jsonData.version.includes(qualifier))) {
const versionSplit = version.split('.');
const patch = parseInt(versionSplit.pop());
version = [...versionSplit, patch + 1].join('.');
}

//get current git hash
// get current git hash
const hash = execSync('git rev-parse --short HEAD', execOpts).trim();

//check for changes to publish
// check for changes to publish
const changes = execSync('git log -1 --pretty=%B', execOpts);

const autoPublish = ['feat', 'fix', 'refactor', 'perf'];
Expand All @@ -31,7 +30,7 @@ const commitRegex = /^(revert: )?(feat|fix|polish|docs|style|refactor|perf|test|
let change = commitRegex.exec(changes);
if (change) {

//find specific changes to publish
// find specific changes to publish
while (change) {
if (autoPublish.includes(change[2])) {
publish = true;
Expand All @@ -44,12 +43,12 @@ if (change) {

if (publish) {

//set version of package.json
// set version of package.json
execSync(`npm version ${version}-dev.${hash} --git-tag-version false`, execOpts);

//create dist files
// create dist files
execSync('npm run compile && npm run compile-rtl && npm run build-scss', execOpts);

//publish to dev tag
// publish to dev tag
execSync('npm publish --tag dev', execOpts);
}

0 comments on commit 89c9807

Please sign in to comment.