diff --git a/bin/shjs b/bin/shjs index faa9995..d239a7a 100755 --- a/bin/shjs +++ b/bin/shjs @@ -7,7 +7,8 @@ if (process.argv.length < 3) { process.exit(1); } -var scriptName = process.argv[2]; +var args, + scriptName = process.argv[2]; env['NODE_PATH'] = __dirname + '/../..'; if (!scriptName.match(/\.js/) && !scriptName.match(/\.coffee/)) { @@ -23,13 +24,20 @@ if (!test('-f', scriptName)) { process.exit(1); } +args = process.argv.slice(3); + +for (var i = 0, l = args.length; i < l; i++) { + if (args[i][0] !== "-"){ + args[i] = '"' + args[i] + '"'; // fixes arguments with multiple words + } +} if (scriptName.match(/\.coffee$/)) { // // CoffeeScript // if (which('coffee')) { - exec('coffee ' + scriptName, { async: true }); + exec('coffee ' + scriptName + ' ' + args.join(' '), { async: true }); } else { console.log('ShellJS: CoffeeScript interpreter not found'); console.log(); @@ -39,5 +47,5 @@ if (scriptName.match(/\.coffee$/)) { // // JavaScript // - exec('node ' + scriptName, { async: true }); + exec('node ' + scriptName + ' ' + args.join(' '), { async: true }); }