From 9c018ecbde0943922326baa007032a1f85d5aad1 Mon Sep 17 00:00:00 2001 From: John Pignata Date: Fri, 11 Mar 2016 18:48:40 -0500 Subject: [PATCH] Don't try to parse output until finished I switched to spawn from exec in order to try to stream issues as they were reported by grep but node will pass chunks of output that may not terminate with a line break causing a line to straddle two chunks. For now buffer all of the data and output issues on exit. In another PR I'll clean this up. --- lib/fix-me.js | 11 +++++++---- test/fix-me.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) 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); }); }); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy