Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #36 from Zanisimo/process-arguments

Passed process arguments to executable script
  • Loading branch information...
commit f58dcd12e27d282eabbed1a93e2d435bce1e0569 2 parents 7780ddc + 68c452c
@arturadib authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 bin/shjs
View
14 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 });
}
Please sign in to comment.
Something went wrong with that request. Please try again.