/
githubmirror
/
babel
Обзор
Документация
Войти
/
githubmirror
/
babel
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/babel-node/src/split-args.ts
47 строк
1 KB
Huáng Jùnliàng
Improve Unicode handling in code-frame tokenizer (#17589)
14 ноя 2025, 16:03
Не верифицирован
14 ноя 2025, 16:03
c92c491
Код
Авторство
О чём код?
import _nodeFlagsWithValue from "../data/node-flags-with-value.json" with { type: "json" }; export const nodeFlagsWithValue = new Set(_nodeFlagsWithValue); const nodeFlagsWithNoFile = new Set(["-p", "--print", "-e", "--eval"]); export function splitArgs(argv: string[], extraOptionsWithValue?: Set<string>) { const programArgs: string[] = []; let explicitSeparator = false; let ignoreFileName = null; let i = 0; for (; i < argv.length; i++) { const arg = argv[i]; if (arg === "-") break; if (arg === "--") { explicitSeparator = true; i++; break; } if (arg.startsWith("-")) { programArgs.push(arg); if ( (nodeFlagsWithValue.has(arg) || extraOptionsWithValue?.has(arg)) && i < argv.length - 1 && !argv[i + 1].startsWith("-") ) { i++; programArgs.push(argv[i]); } if (nodeFlagsWithNoFile.has(arg)) ignoreFileName ??= true; } else if (i === 0 && arg === "inspect") { programArgs.push(arg); ignoreFileName = false; } else { break; } } const fileName = !ignoreFileName && i < argv.length ? argv[i++] : null; const userArgs = argv.slice(i); return { programArgs, fileName, userArgs, explicitSeparator }; }