Files
now-deployment/node_modules/now/dist/util/get-subcommand.ts
2019-10-17 12:36:15 +09:00

20 lines
417 B
TypeScript

type CommandConfig = {
[command: string]: string[];
};
export default function getSubcommand(
cliArgs: string[],
config: CommandConfig
) {
const [subcommand, ...rest] = cliArgs;
for (const k of Object.keys(config)) {
if (k !== 'default' && config[k].indexOf(subcommand) !== -1) {
return { subcommand: k, args: rest };
}
}
return {
subcommand: config.default,
args: cliArgs
};
}