From d8c2aed4bc6f2603f7b6effec6827d55dd4cab0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=A8=EF=BD=8F=EF=BD=8E=EF=BD=87=EF=BD=81=EF=BD=92?= =?UTF-8?q?=EF=BD=83?= Date: Sat, 1 Dec 2018 23:43:31 +0700 Subject: [PATCH] No join, no split --- src/js/commands/index.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/js/commands/index.js b/src/js/commands/index.js index 4ad8128f..133dbe78 100644 --- a/src/js/commands/index.js +++ b/src/js/commands/index.js @@ -127,7 +127,7 @@ var parse = function(str) { // before our "stuff" we can simply // split on space-groups and grab everything after // the second: - options = str.match(/('.*?'|".*?"|\S+)/g).slice(2).join(' '); + options = str.match(/('.*?'|".*?"|\S+)/g).slice(2); } }); }); @@ -170,11 +170,8 @@ function CommandOptionParser(vcs, method, options) { } CommandOptionParser.prototype.explodeAndSet = function() { - // TODO -- this is ugly - // split on spaces, except when inside quotes - var exploded = this.rawOptions.match(/('.*?'|".*?"|\S+)/g) || []; - for (var i = 0; i < exploded.length; i++) { - var part = exploded[i]; + for (var i = 0; i < this.rawOptions.length; i++) { + var part = this.rawOptions[i]; if (part.slice(0,1) == '-') { // it's an option, check supportedMap @@ -187,7 +184,7 @@ CommandOptionParser.prototype.explodeAndSet = function() { }); } - var next = exploded[i + 1]; + var next = this.rawOptions[i + 1]; var optionArgs = []; if (next && next.slice(0,1) !== '-') { // only store the next argument as this