string-argv
Advanced tools
Comparing version 0.1.2 to 0.2.0
12
index.js
@@ -7,9 +7,9 @@ "use strict"; | ||
function parseArgsStringToArgv(value, env, file) { | ||
// ([^\s'"]+(['"])([^\2]*?)\2) Match `text"quotes text"` | ||
// ([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*) Matches nested quotes until the first space outside of quotes | ||
// [^\s'"] or Match if not a space ' or " | ||
// [^\s'"]+ or Match if not a space ' or " | ||
// (['"])([^\4]*?)\4 or Match "quoted text" without quotes | ||
// `\2` and `\4` are a backreference to the quote style (' or ") captured | ||
var myRegexp = /([^\s'"]+(['"])([^\2]*?)\2)|[^\s'"]+|(['"])([^\4]*?)\4/gi; | ||
// (['"])([^\5]*?)\5 or Match "quoted text" without quotes | ||
// `\3` and `\5` are a backreference to the quote style (' or ") captured | ||
var myRegexp = /([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi; | ||
var myString = value; | ||
@@ -31,3 +31,3 @@ var myArray = [ | ||
// Index 0 is the matched text, which we use if no captured group exists | ||
myArray.push(firstString(match[1], match[5], match[0])); | ||
myArray.push(firstString(match[1], match[6], match[0])); | ||
} | ||
@@ -34,0 +34,0 @@ } while (match !== null); |
{ | ||
"name": "string-argv", | ||
"description": "string-argv parses a string into an argument array to mimic process.argv. This is useful when testing Command Line Utilities that you want to pass arguments to.", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ { |
6331
6