Skip to content

Instantly share code, notes, and snippets.

@quidmonkey
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save quidmonkey/10910240 to your computer and use it in GitHub Desktop.

Select an option

Save quidmonkey/10910240 to your computer and use it in GitHub Desktop.
Changelogs for Grunt
{
"builds": {},
"lastSince": null
}
grunt.registerTask('changelog', 'Create git changelog', function () {
var exec = require('child_process').exec;
var path = require('path');
var cmd;
var d = new Date();
var data = grunt.file.readJSON('build.json');
var now = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate(); // yyyy-mm-dd
var since = grunt.option('since') || data.lastSince || now;
var targetFile = path.normalize(__dirname + '/changelogs/changelog_since_' + since + '.txt');
// save current date as the next target changelog startdate
if (!data.lastSince || data.lastSince !== since) {
data.lastSince = since;
data.builds[new Date().toString()] = since;
grunt.file.write('build.json', JSON.stringify(data, null, 4));
}
// create changelog
cmd = 'git log --name-only --since=' + since + ' > ' + targetFile;
exec(cmd);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment