Skip to content

Commit

Permalink
gyp: send spawned output to logger
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblock committed Dec 3, 2019
1 parent 6b8f265 commit e641270
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/node-gyp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit e641270

Please sign in to comment.