-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a script for writing change logs WIP
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var util = require('util') | ||
var fs = require('fs') | ||
var exec = require('child_process').exec; | ||
var child; | ||
|
||
var prevTag = "v0.0.22"; | ||
var nextTag = "v0.0.23"; | ||
|
||
|
||
// Executes the git log command | ||
child = exec('git log '+ prevTag +'...'+ nextTag +' --pretty=format:"{ \\"author\\" : \\"%an\\", \\"commit\\" : \\"%h\\", \\"date\\" : \\"%ar\\", \\"title\\" : \\"%s\\" },"', function (error, stdout, stderr) { | ||
|
||
var jsonStr = "{ \"data\" : [ " + stdout.toString(); | ||
jsonStr = jsonStr.substr(0, jsonStr.length - 1) + " ] } "; | ||
|
||
try { | ||
var json = JSON.parse(jsonStr); | ||
json = json.data; | ||
|
||
console.log("Parsed JSON" ) | ||
|
||
var changes = ""; | ||
for ( var i = 0, l = json.length; i < l; i++ ) | ||
changes += `* ${json[i].title} - see ${json[i].commit} \n`; | ||
|
||
try { | ||
fs.writeFile( 'changes.md', changes, function(err){ | ||
if (err) | ||
throw err; | ||
console.log('It\'s saved!'); | ||
}); | ||
} | ||
catch(err){ | ||
console.log('Could not write file: ' + err); | ||
} | ||
} | ||
catch(err){ | ||
console.log('Could not parse JSON: ' + err); | ||
console.log('JSON STRING: ' + jsonStr); | ||
} | ||
|
||
|
||
if (error !== null) { | ||
console.log('exec error: ' + error); | ||
} | ||
}); |