Last active
January 17, 2016 18:23
-
-
Save dolftax/dc0d9b1ff8da8e285f9b to your computer and use it in GitHub Desktop.
Version incrementer
This file contains hidden or 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
var replaceStream = require('replacestream') | |
var fs = require('fs') | |
var mode = process.argv[2] | |
var exec = require('child_process').exec | |
if(process.argv[2]) { | |
fs.readFile(process.cwd() + '/VERSION', function(err, data) { | |
var verArr = data.toString('utf8').split('\n')[0].split('.') | |
var oldVer = verArr[0] + '.' + verArr[1] + '.' + verArr[2] | |
switch(mode) { | |
case 1: | |
var newVer = verArr[0]+1 + '.' + verArr[1] + '.' + verArr[2] | |
break | |
case 2: | |
var newVer = verArr[0] + '.' + verArr[1]+1 + '.' + verArr[2] | |
break | |
case 3: | |
var newVer = verArr[0] + '.' + verArr[1] + '.' + verArr[2]+1 | |
} | |
console.log(oldVer + ' ' + newVer) | |
fs.createReadStream(process.cwd() + '/VERSION') | |
.pipe(replaceStream(oldVer, newVer)) | |
.pipe(process.stdout) | |
fs.exists('package.json', function() { | |
fs.createReadStream(process.cwd() + '/package.json') | |
.pipe(replaceStream(oldVer, newVer, { limit: 1})) | |
.pipe(process.stdout) | |
exec('npm shrinkwrap -dev') | |
}) | |
fs.exists('bower.json', function() { | |
fs.createReadStream(process.cwd() + '/bower.json') | |
.pipe(replaceStream(oldVer, newVer, { limit: 1})) | |
.pipe(process.stdout) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment