mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-18 16:03:37 +00:00
Merge pull request #36 from Zanisimo/process-arguments
Passed process arguments to executable script
This commit is contained in:
commit
f58dcd12e2
14
bin/shjs
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 });
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user