diff --git a/lib/fix-me.js b/lib/fix-me.js index a5453b0..55bdcc8 100644 --- a/lib/fix-me.js +++ b/lib/fix-me.js @@ -38,14 +38,17 @@ FixMe.prototype.runEngine = function(){ FixMe.prototype.find = function(files, strings){ var fixmeStrings = '(' + strings.join('|') + ')'; var grep = spawn('grep', ['-nHwoEr', fixmeStrings].concat(files)); + var output = ""; var self = this; - grep.stdout.on('data', function (data) { - var results = data.toString(); + grep.stdout.on('data', function(data) { + output += data.toString(); + }); - if (results !== ""){ + grep.stdout.on('close', function() { + if (output !== ""){ // Parses grep output - var lines = results.split("\n"); + var lines = output.split("\n"); lines.forEach(function(line, index, array){ // grep spits out an extra line that we can ignore diff --git a/test/fix-me.js b/test/fix-me.js index cfa7724..7211afa 100644 --- a/test/fix-me.js +++ b/test/fix-me.js @@ -25,7 +25,7 @@ describe("fixMe", function(){ expect(capturedText).to.eq('{"type":"issue","check_name":"TODO","description":"TODO found","categories":["Bug Risk"],"location":{"path":"test/fixtures/code/src/code/test.js","lines":{"begin":5,"end":5}}}\0\n'); done(); - }, 10); + }, 100); }); });