Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function generateHandler(
args: BaseGenerateArguments & Context
): Promise {
// Load config
const globalConfig = await searchConfig(args.cwd);
const config = {
...globalConfig,
...resolveConfig(globalConfig, args)
};
if (!config.components.length) {
throw new CLIError("No components are given", {
output:
"No components are given. Set components in a config file or in arguments."
});
}
// Set env
if (args.env) {
const env = await importEnv(args.cwd);
function resolveConfig(
base: Config,
args: BaseGenerateArguments
): Required {
const { components = [], require = [] } = args.env
? getConfig(base, args.env)
: base;
return {
components:
args.components && args.components.length ? args.components : components,
require: [...require, ...(args.require || [])]
};
}