UNPKG

@nx/expo

Version:

The Expo Plugin for Nx contains executors and generators for managing and developing an expo application within your workspace. For example, you can directly build for different target platforms as well as generate projects and publish your code.

64 lines (63 loc) 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = buildExecutor; const devkit_1 = require("@nx/devkit"); const path_1 = require("path"); const child_process_1 = require("child_process"); const resolve_eas_1 = require("../../utils/resolve-eas"); const install_impl_1 = require("../install/install.impl"); let childProcess; async function* buildExecutor(options, context) { const projectRoot = context.projectsConfigurations.projects[context.projectName].root; try { await (0, install_impl_1.installAndUpdatePackageJson)(context, { packages: ['expo-updates'], }); await runCliUpdate(context.root, projectRoot, options); yield { success: true }; } finally { if (childProcess) { childProcess.kill(); } } } function runCliUpdate(workspaceRoot, projectRoot, options) { return new Promise((resolve, reject) => { childProcess = (0, child_process_1.fork)((0, resolve_eas_1.resolveEas)(workspaceRoot), ['update', ...createUpdateOptions(options)], { cwd: (0, path_1.resolve)(workspaceRoot, projectRoot), env: process.env }); // Ensure the child process is killed when the parent exits process.on('exit', () => childProcess.kill()); process.on('SIGTERM', () => childProcess.kill()); childProcess.on('error', (err) => { reject(err); }); childProcess.on('exit', (code) => { if (code === 0) { resolve(code); } else { reject(code); } }); }); } function createUpdateOptions(options) { return Object.keys(options).reduce((acc, k) => { const v = options[k]; if (typeof v === 'boolean') { if (k === 'interactive') { if (v === false) { acc.push('--non-interactive'); } } else if (v === true) { // when true, does not need to pass the value true, just need to pass the flag in kebob case acc.push(`--${(0, devkit_1.names)(k).fileName}`); } } else { acc.push(`--${(0, devkit_1.names)(k).fileName}`, v); } return acc; }, []); }