Skip to content

Instantly share code, notes, and snippets.

@chakrit
Created June 19, 2012 04:43
Show Gist options
  • Save chakrit/2952320 to your computer and use it in GitHub Desktop.
Save chakrit/2952320 to your computer and use it in GitHub Desktop.
Jake tasks
var fs = require('fs')
, semver = require('semver')
, log = console.log;
var pack = JSON.parse(fs.readFileSync('./package.json'));
// JAKE BUMP
desc('Shorthand for bump:build');
task('bump', ['bump:build'], function() { });
namespace('bump', function() {
var components = ['major', 'minor', 'patch', 'build'];
for (var i in components) (function(component, i) {
desc('Bump ' + component + ' version number.');
task(component, [], function() {
var newVersion = semver.inc(pack.version, component)
, text = fs.readFileSync('./package.json');
text = text.toString();
text = text.replace(pack.version, newVersion);
fs.writeFileSync('./package.json', text);
log('version: ' + newVersion);
});
})(components[i], i);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment