| 370 | } |
| 371 | // https://github.com/jimmycuadra/shellwords/blob/main/src/shellwords.ts |
| 372 | const scan = (string: string, pattern: RegExp, callback: (match: RegExpMatchArray) => void) => { |
| 373 | let result = '' |
| 374 | |
| 375 | while (string.length > 0) { |
| 376 | const match = string.match(pattern) |
| 377 | |
| 378 | if (match && match.index != null && match[0] != null) { |
| 379 | result += string.slice(0, match.index) |
| 380 | result += callback(match) |
| 381 | string = string.slice(match.index + match[0].length) |
| 382 | } else { |
| 383 | result += string |
| 384 | string = '' |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | return result |
| 389 | } |
| 390 | /** |
| 391 | * Splits a string into an array of tokens in the same way the UNIX Bourne shell does. |
| 392 | * https://github.com/jimmycuadra/shellwords/blob/main/src/shellwords.ts |