(rawArguments, detailedOptions, logger, keys)
| 6 | import normalizeCliOptions from "./normalize-cli-options.js"; |
| 7 | |
| 8 | function parseArgv(rawArguments, detailedOptions, logger, keys) { |
| 9 | const minimistOptions = createMinimistOptions(detailedOptions); |
| 10 | let argv = minimist(rawArguments, minimistOptions); |
| 11 | |
| 12 | if (keys) { |
| 13 | detailedOptions = detailedOptions.filter((option) => |
| 14 | keys.includes(option.name), |
| 15 | ); |
| 16 | argv = pick(argv, keys); |
| 17 | } |
| 18 | |
| 19 | const normalized = normalizeCliOptions(argv, detailedOptions, { logger }); |
| 20 | |
| 21 | return { |
| 22 | ...Object.fromEntries( |
| 23 | Object.entries(normalized).map(([key, value]) => { |
| 24 | const option = detailedOptions.find(({ name }) => name === key) || {}; |
| 25 | // If the flag is a prettier API option, use the option name |
| 26 | // Otherwise use camel case for readability |
| 27 | // `--ignore-unknown` -> `ignoreUnknown` |
| 28 | return [option.forwardToApi || camelCase(key), value]; |
| 29 | }), |
| 30 | ), |
| 31 | _: normalized._, |
| 32 | get __raw() { |
| 33 | return argv; |
| 34 | }, |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | const { detailedOptions: detailedOptionsWithoutPlugins } = |
| 39 | getContextOptionsWithoutPlugins(); |
no test coverage detected
searching dependent graphs…