Tweak cli config resolution

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
This commit is contained in:
Martín Bigio 2015-10-12 11:59:49 -07:00 committed by facebook-github-bot-0
parent aacd2d90a4
commit f39816eb38
3 changed files with 7 additions and 4 deletions

3
breaking-changes.txt Normal file
View File

@ -0,0 +1,3 @@
0.14:
- D2530161: Need to introduce rn-cli.config.js for existing projects

View File

@ -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) {

View File

@ -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(