Skip to content
Permalink
Browse files

Use a map to quote arguments with spaces

- Avoids boilerplate.
- Removes duplication of `process.argv.slice(2)`.
- Makes it clearer to see what's going on.
  • Loading branch information...
Juan Cruz Viotti
Juan Cruz Viotti committed Oct 16, 2015
1 parent e7d3494 commit 022cb3b71ffd00da5e3255672ddd87080fdd26de
Showing with 7 additions and 10 deletions.
  1. +7 −10 bin/sudo
@@ -1,14 +1,11 @@
#!/usr/bin/env node

var args = [];
for(var i in process.argv.slice(2)){
v=process.argv.slice(2)[i];
if (v.indexOf(' ')!=-1) {
v='"'+v+'"';
var command = process.argv.slice(2).map(function(arg) {
if (arg.indexOf(' ') !== -1) {
return '"' + arg + '"';
}
args.push(v);
}

require('../lib/windosu').exec(
args.join(' ')
)
return arg;
}).join(' ');

require('../lib/windosu').exec(command);

0 comments on commit 022cb3b

Please sign in to comment.
You can’t perform that action at this time.