Last active
August 29, 2015 13:59
-
-
Save quidmonkey/10910240 to your computer and use it in GitHub Desktop.
Changelogs for Grunt
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
| { | |
| "builds": {}, | |
| "lastSince": null | |
| } |
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
| 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