Skip to content

Commit 44cf853

Browse files
committed
Fix for 'make' failure when process.env.JOBS is '0'
If you use the environment variable `JOBS` which are set '0' for other purpose, `node-gpy rebuild` will fail to execute `make`. Because the `-j` option of `make` require a non-zero positive integer. Here is a simple repro: ``` $ JOBS=0 npm install nightmare ... > weak@0.3.3 install /home/kui/tmp/nm/node_modules/nightmare/node_modules/phantom/node_modules/dnode/node_modules/weak > node-gyp rebuild make: the `-j' option requires a positive integral argument Usage: make [options] [target] ... Options: -b, -m Ignored for compatibility. -B, --always-make Unconditionally make all targets. -C DIRECTORY, --directory=DIRECTORY Change to DIRECTORY before doing anything. -d Print lots of debugging information. .. ```
1 parent 1e399b4 commit 44cf853

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/build.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ function build (gyp, argv, callback) {
222222
var p = arch === 'x64' ? 'x64' : 'Win32'
223223
argv.push('/p:Configuration=' + buildType + ';Platform=' + p)
224224
if (jobs) {
225-
if (!isNaN(parseInt(jobs, 10))) {
226-
argv.push('/m:' + parseInt(jobs, 10))
225+
var j = parseInt(jobs, 10)
226+
if (!isNaN(j) && j > 0) {
227+
argv.push('/m:' + j)
227228
} else if (jobs.toUpperCase() === 'MAX') {
228229
argv.push('/m:' + require('os').cpus().length)
229230
}
@@ -234,9 +235,10 @@ function build (gyp, argv, callback) {
234235
argv.push('-C')
235236
argv.push('build')
236237
if (jobs) {
237-
if (!isNaN(parseInt(jobs, 10))) {
238+
var j = parseInt(jobs, 10)
239+
if (!isNaN(j) && j > 0) {
238240
argv.push('--jobs')
239-
argv.push(parseInt(jobs, 10))
241+
argv.push(j)
240242
} else if (jobs.toUpperCase() === 'MAX') {
241243
argv.push('--jobs')
242244
argv.push(require('os').cpus().length)

0 commit comments

Comments
 (0)