Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function localRequire(id: string, cwd: string): Promise {
debug("Finding module %s in %s", id, cwd);
const path = await resolve(id, { basedir: cwd });
debug("Importing %s from %s", id, path);
return requireDefault(path);
}
async exec(ctx, argv) {
const { args, options, detail } = parse(argv, this, {
"halt-at-non-option": true
} as any);
if (args.template) {
const cwd = getCWD(options);
const extensions = Object.keys(require.extensions);
const path = await resolve(args.template, {
basedir: cwd,
extensions: extensions.length ? extensions : [".js"]
});
debug("Template path", path);
const template = requireDefault(path);
const cmd = buildTemplateCommand(args.template, template);
return cmd.exec(ctx, unparse(detail).slice(1));
}
return help(this);
}
};
function tryRequire(id: string): any {
try {
return requireDefault(id);
} catch (err) {
if (err.code === "MODULE_NOT_FOUND") {
debug("Module not found:", id);
return {};
}
throw err;
}
}
async function getComponentValue(id: string): Promise {
const mod = requireDefault(id);
if (typeof mod === "function") {
return await mod();
}
return mod;
}
async function localRequire(id: string, cwd: string): Promise {
debug("Finding module %s in %s", id, cwd);
const path = await resolve(id, { basedir: cwd });
debug("Importing %s from %s", id, path);
return requireDefault(path);
}
async exec(ctx, argv) {
const { args, options, detail } = parse(argv, this, {
"halt-at-non-option": true
} as any);
if (args.template) {
const cwd = getCWD(options);
const extensions = Object.keys(require.extensions);
const path = await resolve(args.template, {
basedir: cwd,
extensions: extensions.length ? extensions : [".js"]
});
debug("Template path", path);
const template = requireDefault(path);
const cmd = buildTemplateCommand(args.template, template);
return cmd.exec(ctx, unparse(detail).slice(1));
}
return help(this);
}
};