Browse files

clone process.argv so we don't clobber it (thanks to github.com/kaino…

…snoema)
  • Loading branch information...
1 parent a372250 commit 56c14d6f3c515a316b289665ff7c7d3d0a0ee534 @chriso chriso committed May 13, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 cli.js
View
12 cli.js
@@ -143,18 +143,20 @@ cli.disable = function (/*plugins*/) {
* @param {Boolean} keep_arg0 (optional - default is false)
* @api public
*/
-cli.setArgv = function (arr, keep_arg0) {
- if (!(arr instanceof Array)) {
- arr = arr.split(' ');
+cli.setArgv = function (argv, keep_arg0) {
+ if (typeof argv == 'string') {
+ argv = argv.split(' ');
+ } else {
+ argv = argv.slice();
}
- cli.app = arr.shift();
+ cli.app = argv.shift();
//Strip off argv[0] if it's 'node'
if (!keep_arg0 && 'node' === cli.native.path.basename(cli.app)) {
cli.app = arr.shift();
@kainosnoema
kainosnoema added a line comment May 13, 2011

You've got a problem... the merge left the original line here. It should read:

     cli.app = argv.shift();
@chriso
chriso added a line comment May 13, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
cli.app = cli.native.path.basename(cli.app);
argv_parsed = false;
- cli.args = cli.argv = argv = arr;
+ cli.args = cli.argv = argv;
cli.argc = argv.length;
};
cli.setArgv(process.argv);

0 comments on commit 56c14d6

Please sign in to comment.