1import spawnAsync from '@expo/spawn-async'; 2import process from 'process'; 3 4import { EXPO_DIR } from './Constants'; 5 6type Options = { 7 cwd?: string; 8 stdio?: 'inherit' | 'pipe' | 'ignore'; 9}; 10 11export async function runExpoCliAsync( 12 command: string, 13 args: string[] = [], 14 options: Options = {} 15): Promise<void> { 16 // Don't handle SIGINT/SIGTERM in this process...defer to expo-cli 17 process.on('SIGINT', () => {}); 18 process.on('SIGTERM', () => {}); 19 20 await spawnAsync('npx', ['expo', command, ...args], { 21 cwd: options.cwd || EXPO_DIR, 22 stdio: options.stdio || 'inherit', 23 env: { 24 ...process.env, 25 EXPO_NO_DOCTOR: 'true', 26 }, 27 }); 28} 29 30export async function runCreateExpoAppAsync( 31 name: string, 32 args: string[] = [], 33 options: Options = {} 34): Promise<void> { 35 // Don't handle SIGINT/SIGTERM in this process...defer to expo-cli 36 process.on('SIGINT', () => {}); 37 process.on('SIGTERM', () => {}); 38 39 await spawnAsync('npx', ['create-expo-app', name, ...args], { 40 cwd: options.cwd || EXPO_DIR, 41 stdio: options.stdio || 'inherit', 42 env: { 43 ...process.env, 44 EXPO_NO_DOCTOR: 'true', 45 }, 46 }); 47} 48