Skip to content

Instantly share code, notes, and snippets.

@kylealwyn
Last active October 26, 2016 16:35
Show Gist options
  • Save kylealwyn/96d6b2efa4cb268ae5091dcb96a26751 to your computer and use it in GitHub Desktop.
Save kylealwyn/96d6b2efa4cb268ae5091dcb96a26751 to your computer and use it in GitHub Desktop.
#! /usr/bin/env node
const version = process.argv[2];
if (!version) {
throw new Error('Provide a new version (vX.X.X)')
} else if (version[0] !== 'v') {
version = 'v' + version
}
const exec = require('child_process').exec;
const write = require('fs').writeFileSync;
['bower.json', 'package.json'].forEach(file => {
const package = require(`./${file}`)
package.version = version.substring(1);
write(`./${file}`, JSON.stringify(package, null, 2), 'utf-8');
})
const loop = (commands) => {
if (commands && commands.length) {
const stream = exec(commands.shift())
stream.stdout.on('data', (data) => console.log(data));
stream.stderr.on('data', (error) => {
console.error(error);
});
stream.on('exit', () => loop(commands));
}
}
loop([
'gulp build',
'git add -A',
'git commit -m ' + version,
'git tag ' + version,
'git push',
'git push --tags',
'npm publish'
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment