Skip to content

Commit 6bfb29b

Browse files
committed
Update configure.js
Fixes nodejs#65. Build failure when builddir contains spaces. Solution by @trentm. See trentm@bbd979b
1 parent 7e98c99 commit 6bfb29b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/configure.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
module.exports = exports = configure
32

43
/**
@@ -175,7 +174,7 @@ function configure (gyp, argv, callback) {
175174

176175
var config = process.config || {}
177176
, defaults = config.target_defaults
178-
, variables = config.variables
177+
, variablesa = config.variables
179178

180179
// default "config.variables"
181180
if (!variables) variables = config.variables = {}
@@ -303,13 +302,18 @@ function configure (gyp, argv, callback) {
303302
// Windows expects an absolute path
304303
output_dir = buildDir
305304
}
306-
307-
argv.push('-I', addon_gypi)
308-
argv.push('-I', common_gypi)
305+
306+
// Fix for spaces and other special characters in path.
307+
function shellEscape(str) {
308+
return str.replace(/(["\s'$`\\])/g, '\\$1');
309+
};
310+
311+
argv.push('-I', shellEscape(addon_gypi))
312+
argv.push('-I', shellEscape(common_gypi))
309313
argv.push('-Dlibrary=shared_library')
310314
argv.push('-Dvisibility=default')
311-
argv.push('-Dnode_root_dir=' + nodeDir)
312-
argv.push('-Dmodule_root_dir=' + process.cwd())
315+
argv.push('-Dnode_root_dir=' + shellEscape(nodeDir))
316+
argv.push('-Dmodule_root_dir=' + shellEscape(process.cwd()))
313317
argv.push('--depth=.')
314318

315319
// tell gyp to write the Makefile/Solution files into output_dir

0 commit comments

Comments
 (0)