Skip to content

Commit

Permalink
Use the first matched string, even if it's an empty string (fixes #12)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMessinger committed Mar 10, 2019
1 parent ada7eef commit c90017f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@ function parseArgsStringToArgv(value, env, file) {
if (match !== null) {
// Index 1 in the array is the captured group if it exists
// Index 0 is the matched text, which we use if no captured group exists
myArray.push(match[1] || match[5] || match[0]);
myArray.push(firstString(match[1], match[5], match[0]));
}
} while (match !== null);

return myArray;
}

// Accepts any number of arguments, and returns the first one that is a string
// (even an empty string)
function firstString() {
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (typeof arg === "string") {
return arg;
}
}
}

0 comments on commit c90017f

Please sign in to comment.