From 91ec525b6bfe17c7c78c794078e0cb831c10a575 Mon Sep 17 00:00:00 2001 From: Marco Ceppi Date: Wed, 30 Jan 2013 17:07:44 -0500 Subject: [PATCH] A rough, possibly sad, way to fix #4 string escapes from --pretty=format: --- index.js | 11 +++++++++-- package.json | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index baa5add..768006f 100755 --- a/index.js +++ b/index.js @@ -1,4 +1,7 @@ var exec = require('child_process').exec + , async = require('async') + , delimiter = '|##|^' + , eol = '*||*}'; function _command (cmd, cb) { exec(cmd, function (err, stdout, stderr) { @@ -20,9 +23,13 @@ module.exports = { _command('git describe --always --tag --abbrev=0', cb) } , log : function (cb) { - _command('git log --no-color --pretty=format:\'[ "%H", "%s", "%cr", "%an" ],\' --abbrev-commit', function (str) { + _command('git log --no-color --pretty=format:"%H'+delimiter+'%s'+delimiter+'%cr'+delimiter+'%an'+eol+'" --abbrev-commit', function (str) { str = str.substr(0, str.length-1) - cb(JSON.parse('[' + str + ']')) + async.mapSeries(str.split(eol), function(line, next) { + next(null, line.split(delimiter)); + }, function(err, log) { + cb(log); + }); }) } } diff --git a/package.json b/package.json index 386cba6..c6c4dcf 100755 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "directories" : { "example" : "example" }, - "dependencies" : {}, + "dependencies" : { + "async": "*" + }, "devDependencies" : {}, "scripts" : {}, "repository" : {