UNPKG

@nx/react-native

Version:

The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: -Integration with libraries such as Jest, Detox, and Storybook. -Scaffolding for creating buildable libraries th

47 lines (46 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = upgradeExecutor; exports.runCliUpgrade = runCliUpgrade; const path_1 = require("path"); const child_process_1 = require("child_process"); /** * This executor is equivalent to `npx react-native upgrade`. * https://github.com/react-native-community/cli/blob/main/packages/cli/src/commands/upgrade/upgrade.ts */ async function* upgradeExecutor(options, context) { const projectRoot = context.projectsConfigurations.projects[context.projectName].root; await runCliUpgrade(context.root, projectRoot); yield { success: true }; } function runCliUpgrade(workspaceRoot, projectRoot) { return new Promise((resolve, reject) => { const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['upgrade'], { stdio: 'inherit', cwd: (0, path_1.resolve)(workspaceRoot, projectRoot), env: process.env, }); /** * Ensure the child process is killed when the parent exits */ const processExitListener = (signal) => () => { childProcess.kill(signal); process.exit(); }; process.once('exit', (signal) => childProcess.kill(signal)); process.once('SIGTERM', processExitListener); process.once('SIGINT', processExitListener); process.once('SIGQUIT', processExitListener); childProcess.on('error', (err) => { reject(err); }); childProcess.on('exit', (code) => { if (code === 0) { resolve(childProcess); } else { reject(code); } }); }); }