UNPKG

@onereach/orest-input-cli

Version:

The tool for creating, serving, and publishing OREST Inputs

25 lines (19 loc) 590 B
const pkgDir = require('pkg-dir'); const execa = require('execa'); const chalk = require('chalk'); const path = require('path'); module.exports = async function runNpmScript( task, additionalArgs = [], relDirPath = '', options = {} ) { const projectRoot = await pkgDir(path.resolve(process.cwd(), relDirPath)); const args = [task, ...additionalArgs]; if (!options.noRun) { args.unshift('run'); } const command = chalk.dim(`npm ${args.join(' ')}`); console.log(`Running ${command}`); return await execa('npm', args, { cwd: projectRoot, stdio: 'inherit' }); };