UNPKG

nx-mesh

Version:
36 lines 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runCodegenCli = exports.childProcess = void 0; const tslib_1 = require("tslib"); const node_child_process_1 = require("node:child_process"); const arguments_1 = require("./arguments"); function runCodegenCli(options, context, processOptions) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const args = (0, arguments_1.getCliArguments)(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-codegen', ...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({}, process.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.runCodegenCli = runCodegenCli; //# sourceMappingURL=cli.js.map