(raw: string)
| 251 | } |
| 252 | |
| 253 | function tokenizeArgs(raw: string): string[] { |
| 254 | const out: string[] = []; |
| 255 | let current = ''; |
| 256 | let quote: '"' | "'" | undefined; |
| 257 | let hasContent = false; |
| 258 | |
| 259 | for (const char of raw) { |
| 260 | if (quote !== undefined) { |
| 261 | if (char === quote) { |
| 262 | quote = undefined; |
| 263 | } else { |
| 264 | current += char; |
| 265 | hasContent = true; |
| 266 | } |
| 267 | continue; |
| 268 | } |
| 269 | if (char === '"' || char === "'") { |
| 270 | quote = char; |
| 271 | hasContent = true; |
| 272 | continue; |
| 273 | } |
| 274 | if (/\s/.test(char)) { |
| 275 | if (hasContent) { |
| 276 | out.push(current); |
| 277 | current = ''; |
| 278 | hasContent = false; |
| 279 | } |
| 280 | continue; |
| 281 | } |
| 282 | current += char; |
| 283 | hasContent = true; |
| 284 | } |
| 285 | |
| 286 | if (hasContent) out.push(current); |
| 287 | return out; |
| 288 | } |
| 289 | |
| 290 | function nonEmptyString(value: unknown): string | undefined { |
| 291 | return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined; |
no test coverage detected