From c253bdd71ccee26e91b7fe67828bc8a935bd47c2 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 13 Jul 2017 16:02:19 -0400 Subject: [PATCH] Use eachline@3.0.5 from npm instead of our own fork. The pull request corresponding to our fork is not going to be merged, so it's better to use the alternative this.finished API available in newer versions of the upstream package. https://github.com/williamkapke/node-eachline/pull/4 --- scripts/dev-bundle-server-package.js | 4 +--- scripts/dev-bundle-tool-package.js | 4 +--- tools/cordova/run-targets.js | 5 +++++ tools/runners/run-app.js | 7 +++++-- tools/shell-client.js | 5 +++++ tools/utils/utils.js | 13 +++++++++++-- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/scripts/dev-bundle-server-package.js b/scripts/dev-bundle-server-package.js index cb9ca95d7b..d5a0e3c987 100644 --- a/scripts/dev-bundle-server-package.js +++ b/scripts/dev-bundle-server-package.js @@ -22,9 +22,7 @@ var packageJson = { // These are only used in dev mode (by shell.js) so end-users can avoid // needing to install them if they use `npm install --production`. devDependencies: { - // 2.4.0 (more or less, the package.json change isn't committed) plus our PR - // https://github.com/williamwicks/node-eachline/pull/4 - eachline: "https://github.com/meteor/node-eachline/tarball/ff89722ff94e6b6a08652bf5f44c8fffea8a21da", + eachline: "3.0.5", chalk: "0.5.1" } }; diff --git a/scripts/dev-bundle-tool-package.js b/scripts/dev-bundle-tool-package.js index 5ddf96cc5e..ca971bb305 100644 --- a/scripts/dev-bundle-tool-package.js +++ b/scripts/dev-bundle-tool-package.js @@ -47,9 +47,7 @@ var packageJson = { // workaround from the tool. "commonmark": "0.15.0", escope: "3.2.0", - // 2.4.0 (more or less, the package.json change isn't committed) plus our PR - // https://github.com/williamwicks/node-eachline/pull/4 - eachline: "https://github.com/meteor/node-eachline/tarball/ff89722ff94e6b6a08652bf5f44c8fffea8a21da", + eachline: "3.0.5", pathwatcher: "7.1.0", optimism: "0.3.3", 'lru-cache': '4.0.1', diff --git a/tools/cordova/run-targets.js b/tools/cordova/run-targets.js index d04a1efff2..b841ec3679 100644 --- a/tools/cordova/run-targets.js +++ b/tools/cordova/run-targets.js @@ -147,6 +147,11 @@ export class AndroidRunTarget extends CordovaRunTarget { loadIsopacket('cordova-support')['logging']; const logStream = eachline((line) => { + if (! line && this.finished) { + // Skip blank line at end of stream. + return; + } + const logEntry = logFromAndroidLogcatLine(Log, line); if (logEntry) { return `${logEntry}\n`; diff --git a/tools/runners/run-app.js b/tools/runners/run-app.js index b7d3806401..01ae073fef 100644 --- a/tools/runners/run-app.js +++ b/tools/runners/run-app.js @@ -85,10 +85,13 @@ _.extend(AppProcess.prototype, { // Start the app! self.proc = self._spawn(); - // Send stdout and stderr to the runLog var realEachline = require('eachline'); function eachline(stream, encoding, callback) { - realEachline(stream, encoding, (...args) => void(callback(...args))); + return realEachline(stream, encoding, function (line) { + if (line || ! this.finished) { + callback.apply(this, arguments); + } + }); } eachline(self.proc.stdout, 'utf8', async function (line) { diff --git a/tools/shell-client.js b/tools/shell-client.js index f1543dbd68..ba84bf8fa5 100644 --- a/tools/shell-client.js +++ b/tools/shell-client.js @@ -182,6 +182,11 @@ Cp.setUpSocket = function setUpSocket(sock, key) { sock.pipe(process.stdout); eachline(sock, "utf8", function(line) { + if (! line && this.finished) { + // Ignore blank lines at the end of the socket stream. + return; + } + self.exitOnClose = line.indexOf(EXITING_MESSAGE) >= 0; }); diff --git a/tools/utils/utils.js b/tools/utils/utils.js index 27ba7b7bdd..42a39d1778 100644 --- a/tools/utils/utils.js +++ b/tools/utils/utils.js @@ -542,11 +542,15 @@ exports.execFileSync = function (file, args, opts) { var p = child_process.spawn(file, args, opts); eachline(p.stdout, fiberHelpers.bindEnvironment(function (line) { - process.stdout.write(line + '\n'); + if (line || ! this.finished) { + process.stdout.write(line + '\n'); + } })); eachline(p.stderr, fiberHelpers.bindEnvironment(function (line) { - process.stderr.write(line + '\n'); + if (line || ! this.finished) { + process.stderr.write(line + '\n'); + } })); return { @@ -577,6 +581,11 @@ exports.execFileAsync = function (file, args, opts) { var mapper = opts.lineMapper || _.identity; var logOutput = fiberHelpers.bindEnvironment(function (line) { + if (! line && this.finished) { + // Ignore blank lines at the end of the output stream. + return; + } + if (opts.verbose) { line = mapper(line); if (line) {