From e6412702d11d3df54a36d087535e65fcf9b0c734 Mon Sep 17 00:00:00 2001 From: Cameron Tacklind Date: Tue, 3 Dec 2019 00:40:46 -0800 Subject: [PATCH] gyp: send spawned output to logger Fixes https://github.com/nodejs/node-gyp/issues/532 --- lib/node-gyp.js | 13 +++++++++++-- package.json | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/node-gyp.js b/lib/node-gyp.js index 9d24103900..5c021ddd75 100644 --- a/lib/node-gyp.js +++ b/lib/node-gyp.js @@ -3,6 +3,7 @@ const path = require('path') const nopt = require('nopt') const log = require('npmlog') +const split = require('split2') const childProcess = require('child_process') const EE = require('events').EventEmitter const inherits = require('util').inherits @@ -166,10 +167,18 @@ proto.spawn = function spawn (command, args, opts) { if (!opts) { opts = {} } + + var cp = childProcess.spawn(command, args, opts) + if (!opts.silent && !opts.stdio) { - opts.stdio = [0, 1, 2] + cp.stdout.pipe(split()).on('data', function (line) { + log.notice('spawn stdout', line) + }) + cp.stderr.pipe(split()).on('data', function (line) { + log.error('spawn stderr', line) + }) } - var cp = childProcess.spawn(command, args, opts) + log.info('spawn', command) log.info('spawn args', args) return cp diff --git a/package.json b/package.json index 243738506d..2e86762a83 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "request": "^2.88.0", "rimraf": "^2.6.3", "semver": "^5.7.1", + "split2": "^3.1.1", "tar": "^4.4.12", "which": "^1.3.1" },