From f39816eb389528631db17c2829bc716b336cd965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Bigio?= Date: Mon, 12 Oct 2015 11:59:49 -0700 Subject: [PATCH] Tweak cli config resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @​public We need to tweak the resolution algorithm to start looking for the config file at the directory where the node script is running. This is needed to make development easier as internally we'll need 2 config files, one for open source and other one for internal use. This won't affect oss as for they we'll generate this file as part of the `init` command. Reviewed By: @vjeux Differential Revision: D2530161 fb-gh-sync-id: 17c21a56a26a91f2671197e8daa36c19adcea8ee --- breaking-changes.txt | 3 +++ private-cli/src/cli.js | 4 ++-- private-cli/src/util/Config.js | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 breaking-changes.txt diff --git a/breaking-changes.txt b/breaking-changes.txt new file mode 100644 index 000000000..fcd61fe41 --- /dev/null +++ b/breaking-changes.txt @@ -0,0 +1,3 @@ +0.14: +- D2530161: Need to introduce rn-cli.config.js for existing projects + diff --git a/private-cli/src/cli.js b/private-cli/src/cli.js index 679c46d00..563ddde73 100644 --- a/private-cli/src/cli.js +++ b/private-cli/src/cli.js @@ -27,7 +27,7 @@ const hiddenCommands = { * Programmatic entry point for the cli. This function runs the given * command passing it the arguments array. */ -function run(command, commandArgs) { +function run(pwd, command, commandArgs) { if (!command) { throw new Error(helpMessage()); } @@ -38,7 +38,7 @@ function run(command, commandArgs) { throw new Error(helpMessage(command)); } - commandToExec(commandArgs, Config.get()).done(); + commandToExec(commandArgs, Config.get(pwd)).done(); } function helpMessage(command) { diff --git a/private-cli/src/util/Config.js b/private-cli/src/util/Config.js index ccd2a43c8..c6bfd3bbc 100644 --- a/private-cli/src/util/Config.js +++ b/private-cli/src/util/Config.js @@ -20,12 +20,12 @@ let cachedConfig = null; * It has to be on any parent directory of the cli. */ const Config = { - get() { + get(pwd) { if (cachedConfig) { return cachedConfig; } - const parentDir = findParentDirectory(__dirname, RN_CLI_CONFIG); + const parentDir = findParentDirectory(pwd, RN_CLI_CONFIG); if (!parentDir) { throw new Error(