From 2f26fe0b352132d3ebd29f27575290a79518e276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 14 Mar 2019 23:18:45 +0100 Subject: [PATCH 1/2] fix: reactNativePath and projectRoot not being parsed by commander --- packages/cli/src/cliEntry.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/cliEntry.js b/packages/cli/src/cliEntry.js index ddc9b97e1..dcd9941c5 100644 --- a/packages/cli/src/cliEntry.js +++ b/packages/cli/src/cliEntry.js @@ -10,6 +10,7 @@ import chalk from 'chalk'; import childProcess from 'child_process'; import commander from 'commander'; +import minimist from 'minimist'; import path from 'path'; import type {CommandT, ContextT} from './tools/types.flow'; import getLegacyConfig from './tools/getLegacyConfig'; @@ -153,12 +154,19 @@ async function setupAndRun() { } } - const root = commander.projectRoot - ? path.resolve(commander.projectRoot) + /** + * At this point, commander arguments are not parsed yet because we need to + * add all the commands and their options. That's why we resort to using + * minimist for parsing some global options. + */ + const options = minimist(process.argv.slice(2)); + + const root = options.projectRoot + ? path.resolve(options.projectRoot) : process.cwd(); - const reactNativePath = commander.reactNativePath - ? path.resolve(commander.reactNativePath) + const reactNativePath = options.reactNativePath + ? path.resolve(options.reactNativePath) : (() => { try { return path.dirname( From ae8cdcf0e62660158dbef566fa80f0ebf39f607e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 14 Mar 2019 23:23:31 +0100 Subject: [PATCH 2/2] add minimist --- yarn.lock | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 7e951d145..3fadcbb86 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5695,10 +5695,15 @@ minimist@0.0.8: version "0.0.8" resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: +minimist@^1.1.1, minimist@^1.1.3: version "1.2.0" resolved "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" +minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + minimist@~0.0.1: version "0.0.10" resolved "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"