1#!/usr/bin/env node 2import chalk from 'chalk'; 3 4import { Command } from '../../bin/cli'; 5import * as Log from '../log'; 6import { assertWithOptionsArgs } from '../utils/args'; 7 8export const expoInstall: Command = async (argv) => { 9 const args = assertWithOptionsArgs( 10 { 11 // Other options are parsed manually. 12 '--help': Boolean, 13 // Aliases 14 '-h': '--help', 15 }, 16 { 17 argv, 18 // Allow other options, we'll throw an error if unexpected values are passed. 19 permissive: true, 20 } 21 ); 22 23 if (args['--help']) { 24 Log.exit( 25 chalk` 26 {bold Description} 27 Install a module or other package to a project 28 29 {bold Usage} 30 $ npx expo install {dim [packages...] [options]} 31 32 {bold Options} 33 --npm Use npm to install dependencies. {dim Default when package-lock.json exists} 34 --yarn Use Yarn to install dependencies. {dim Default when yarn.lock exists} 35 -h, --help Output usage information 36 37 Additional options can be passed to the underlying install command by using {bold --} 38 $ expo install react -- --verbose 39 {dim >} yarn add react --verbose 40 `, 41 0 42 ); 43 } 44 45 // Load modules after the help prompt so `npx expo install -h` shows as fast as possible. 46 const { installAsync } = require('./installAsync') as typeof import('./installAsync'); 47 const { logCmdError } = require('../utils/errors') as typeof import('../utils/errors'); 48 const { resolveArgsAsync } = require('./resolveOptions') as typeof import('./resolveOptions'); 49 50 const { variadic, options, extras } = await resolveArgsAsync(process.argv.slice(3)).catch( 51 logCmdError 52 ); 53 return installAsync(variadic, options, extras).catch(logCmdError); 54}; 55