UNPKG

@quasar/cli

Version:

Quasar Framework - the Global CLI

31 lines (27 loc) 651 B
import { parseArgs } from 'node:util' import { warn } from './logger.js' export function getArgv(options, { strict = true } = {}) { try { const { values, positionals } = parseArgs({ options, strict, allowPositionals: true }) return { ...values, _: positionals } } catch (err) { return { help: true, _: [], // Should be handled if (argv.help) in the caller __warn() { warn( err?.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION' ? err.message : 'Unknown error while parsing arguments' ) warn() process.exit(1) } } } }