Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / node_modules / yargs / lib / tokenize-arg-string.js
1 // take an un-split argv string and tokenize it.
2 module.exports = function (argString) {
3   var i = 0
4   var c = null
5   var opening = null
6   var args = []
7
8   for (var ii = 0; ii < argString.length; ii++) {
9     c = argString.charAt(ii)
10
11     // split on spaces unless we're in quotes.
12     if (c === ' ' && !opening) {
13       i++
14       continue
15     }
16
17     // don't split the string if we're in matching
18     // opening or closing single and double quotes.
19     if (c === opening) {
20       opening = null
21       continue
22     } else if ((c === "'" || c === '"') && !opening) {
23       opening = c
24       continue
25     }
26
27     if (!args[i]) args[i] = ''
28     args[i] += c
29   }
30
31   return args
32 }