Last active
October 26, 2016 16:35
-
-
Save kylealwyn/96d6b2efa4cb268ae5091dcb96a26751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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