UNPKG

1.29 kBJavaScriptView Raw
1#!/usr/bin/env node
2'use strict';
3var spawn = require('cross-spawn').spawn;
4
5run();
6
7function run() {
8 spawn('expo-cli', process.argv.slice(2), { stdio: 'inherit' })
9 .on('exit', function(code) {
10 process.exit(code);
11 })
12 .on('error', function() {
13 console.warn('This command requires Expo CLI.');
14 var rl = require('readline').createInterface({
15 input: process.stdin,
16 output: process.stdout,
17 });
18 rl.question('Do you want to install it globally [Y/n]? ', function(answer) {
19 rl.close();
20 if (/^n/i.test(answer.trim())) {
21 process.exit(1);
22 } else {
23 console.log("Installing the package 'expo-cli'...");
24 spawn('npm', ['install', '--global', '--loglevel', 'error', 'expo-cli'], {
25 stdio: ['inherit', 'ignore', 'inherit'],
26 }).on('close', function(code) {
27 if (code !== 0) {
28 console.error('Installing Expo CLI failed. You can install it manually with:');
29 console.error(' npm install --global expo-cli');
30 process.exit(code);
31 } else {
32 console.log('Expo CLI installed. You can run `expo --help` for instructions.');
33 run();
34 }
35 });
36 }
37 });
38 });
39}