UNPKG

@coat/cli

Version:

TODO: See #3

32 lines (31 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runSingleScript = runSingleScript; var _execa = _interopRequireDefault(require("execa")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Runs a single npm script from a package.json file * with the provided arguments * * @param cwd The working directory where the script should be run from * @param script The name of npm script * @param args Optional arguments that will be passed to the script */ async function runSingleScript(cwd, script, args) { // Run scripts in silent mode to surpress // any npm specific output const npmArgs = ["run", "--silent", script]; if (args !== null && args !== void 0 && args.length) { // Add two dashes ("--") in order for npm run // to pick up the arguments npmArgs.push("--", ...args); } await (0, _execa.default)("npm", npmArgs, { // Inherit the stdio to enable interactive // use cases like jest's watch mode stdio: "inherit", cwd }); }