Closed
Description
cli
const allModulesPaths = require('all-module-paths');
const mod = require('module')
const dirs = allModulesPaths({ paths: mod._nodeModulePaths(proc.cwd()) });
const PATH = dirs.allPaths.binaries.join(':');
/* eslint-disable promise/always-return */
const env = { PATH: `${PATH}:${process.env.PATH}` };
cli(null, { env })
index
export default async function monora(cliArgv, options) {
const argv = Array.isArray(cliArgv) ? cliArgv : proc.argv.slice(2)
const { cwd, tasks, manager, nonStrictBehavior, env } = Object.assign(
{ cwd: proc.cwd() },
options,
);
const pkgPath = resolve(cwd, 'package.json');
const pkg = await import(pkgPath);
const config = await loadConfig(cwd, manager);
let scripts = Object.assign({}, pkg.scripts, pkg.monora, tasks, config);
const cfgPresets = scripts.extends || scripts.preset || scripts.presets;
if (cfgPresets) {
const presetPath = cfgPresets.startsWith('.')
? resolve(cwd, cfgPresets)
: cfgPresets;
scripts = Object.assign({}, scripts, await import(presetPath));
}
// List all available scripts/tasks
// if not one given, e.g. running `$ scripts`
if (argv.length === 0) {
return scripts;
}
const commands = normalizer(scripts, argv, nonStrictBehavior);
return shell(commands, { env, stdio: 'inherit' });
}