From bbd979bca2af5dfe29169ac50db17372fb4971b3 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Wed, 14 Nov 2012 21:02:06 -0800 Subject: [PATCH] issue #65: fix some shell escaping for building in a dir with spaces --- lib/configure.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/configure.js b/lib/configure.js index 08b69026b3..2db43c7ed9 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -387,12 +387,16 @@ function configure (gyp, argv, callback) { output_dir = buildDir } - argv.push('-I', addon_gypi) - argv.push('-I', common_gypi) + function shellEscape(str) { + return str.replace(/(["\s'$`\\])/g, '\\$1'); + }; + + argv.push('-I', shellEscape(addon_gypi)) + argv.push('-I', shellEscape(common_gypi)) argv.push('-Dlibrary=shared_library') argv.push('-Dvisibility=default') - argv.push('-Dnode_root_dir=' + nodeDir) - argv.push('-Dmodule_root_dir=' + process.cwd()) + argv.push('-Dnode_root_dir=' + shellEscape(nodeDir)) + argv.push('-Dmodule_root_dir=' + shellEscape(process.cwd())) argv.push('--depth=.') // tell gyp to write the Makefile/Solution files into output_dir