@tsed/cli-core
Version:
Build your CLI with TypeScript and Decorators
19 lines (18 loc) • 680 B
JavaScript
import { getValue } from "@tsed/core";
import { getCommandMetadata } from "./getCommandMetadata.js";
export function resolveConfiguration(settings) {
const argv = getValue(settings, "argv", process.argv);
const configResolvers = getValue(settings, "configResolvers", []);
const commands = getValue(settings, "commands", []);
const commandOpts = commands
.map((token) => getCommandMetadata(token))
.find((commandOpts) => argv.includes(commandOpts.name));
settings = {
...settings,
commands,
command: commandOpts || {},
argv
};
configResolvers.map((resolver) => resolver(settings));
return settings;
}