nx-mesh
Version:
GraphQL Mesh support for Nx
37 lines • 1.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.runMeshCli = exports.childProcess = void 0;
const tslib_1 = require("tslib");
const node_child_process_1 = require("node:child_process");
const arguments_1 = require("./arguments");
const commands_1 = require("./commands");
function runMeshCli(command, options, context, processOptions) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { args, env } = (0, commands_1.getCommandOptions)(options);
const cliArgs = (0, arguments_1.flatternCliArguments)(args);
return new Promise((resolve, reject) => {
var _a;
exports.childProcess = (0, node_child_process_1.spawn)(`npx`, ['graphql-mesh', command, ...cliArgs], {
stdio: (_a = processOptions === null || processOptions === void 0 ? void 0 : processOptions.stdio) !== null && _a !== void 0 ? _a : [0, 1, 2],
cwd: context.root,
env: Object.assign(Object.assign(Object.assign({}, process.env), env), { FORCE_COLOR: 'true' }),
});
// Ensure the child process is killed when the parent exits
process.on('exit', () => exports.childProcess.kill());
process.on('SIGTERM', () => exports.childProcess.kill());
exports.childProcess.on('error', (err) => {
reject(err);
});
exports.childProcess.on('exit', (code) => {
if (code === 0) {
resolve(code);
}
else {
reject(code);
}
});
});
});
}
exports.runMeshCli = runMeshCli;
//# sourceMappingURL=cli.js.map