@modyo/cli
Version:
Modyo CLI Command line to expose local development tools
35 lines (34 loc) • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.runCommand = void 0;
const tslib_1 = require("tslib");
const node_child_process_1 = require("node:child_process");
const debug_1 = tslib_1.__importDefault(require("debug"));
const debug = (0, debug_1.default)('get/package-managers.ts');
const debugError = (0, debug_1.default)('error:get/package-managers.ts');
async function runCommand(widgetPath, command) {
debug(`try to run command ${command} with npm in ${widgetPath}`);
return new Promise((resolve, reject) => {
try {
const npm = (0, node_child_process_1.spawn)('npm', ['run', command], {
cwd: widgetPath,
shell: true,
});
npm.stdout.pipe(process.stdout);
npm.stderr.pipe(process.stderr);
npm.on('exit', (code, signal) => {
if (code === 0) {
resolve(`${code}, ${signal}`);
}
else {
reject(new Error(`Error running command ${command} with npm`));
}
});
}
catch (error) {
debugError(error);
throw new Error('Please check your npm installation and version to be >=12');
}
});
}
exports.runCommand = runCommand;