Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// MODULES //

var spawn = require( 'child_process' ).spawn;
var proc = require( 'process' );


// FUNCTIONS //
Expand All @@ -31,9 +32,9 @@ var spawn = require( 'child_process' ).spawn;
* @private
* @param {Error} error - error object
*/
function onError( error ) {
function onError(error) {
proc.exitCode = 1;
console.error( 'Error: %s', error.message ); // eslint-disable-line no-console
console.error('Error: %s', error.message); // eslint-disable-line no-console
}

/**
Expand All @@ -43,10 +44,10 @@ function onError( error ) {
* @param {number} code - exit code
* @returns {void}
*/
function onFinish( code ) {
if ( code !== 0 ) {
function onFinish(code) {
if (code !== 0) {
proc.exitCode = code;
return console.error( 'Child process exited with code `'+code + '`.' ); // eslint-disable-line no-console
return console.error('Child process exited with code `' + code + '`.'); // eslint-disable-line no-console
}
}

Expand All @@ -56,8 +57,8 @@ function onFinish( code ) {
* @private
* @param {Buffer} data - standard output
*/
function stdout( data ) {
proc.stdout.write( data );
function stdout(data) {
proc.stdout.write(data);
}

/**
Expand All @@ -66,8 +67,8 @@ function stdout( data ) {
* @private
* @param {Buffer} data - standard error
*/
function stderr( data ) {
proc.stderr.write( data );
function stderr(data) {
proc.stderr.write(data);
}


Expand All @@ -80,7 +81,7 @@ function stderr( data ) {
* @param {string} cwd - current working directory
* @param {string} subpath - subdirectory path
*/
function plugin( dir, cwd, subpath ) {
function plugin(dir, cwd, subpath) {
var opts;
var args;
var proc;
Expand All @@ -91,18 +92,18 @@ function plugin( dir, cwd, subpath ) {
args = [];

// Environment variables:
if ( subpath ) {
subpath = subpath.substring( 17 ); // removes 'lib/node_modules/'
args.push( 'NODE_ADDONS_PATTERN='+subpath );
if (subpath) {
subpath = subpath.substring(17); // removes 'lib/node_modules/'
args.push('NODE_ADDONS_PATTERN=' + subpath);
}
// Target:
args.push( 'install-node-addons' );
args.push('install-node-addons');

proc = spawn( 'make', args, opts );
proc.on( 'error', onError );
proc.stdout.on( 'data', stdout );
proc.stderr.on( 'data', stderr );
proc.on( 'close', onFinish );
proc = spawn('make', args, opts);
proc.on('error', onError);
proc.stdout.on('data', stdout);
proc.stderr.on('data', stderr);
proc.on('close', onFinish);
}


Expand Down