From 48072904423649a1f85820207f063e4a3e0d4bde Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Sun, 20 Mar 2016 18:08:23 -0700 Subject: [PATCH] Fix cli config file on Windows Summary:The local-cli didn't pickup the `rn-cli.config.js` file on Windows because the root of a path is not 1 character long since it is 'C:/' and broke the path operations. This just substrings the root length instead of hard coding 1. Also fix a lint warning in the file about path concatenation but using string interpolation. Fixes #5686 **Test plan (required)** Tested that the `findParentDirectory` function returns the path of `rn-cli.config.js` if present or null if not on both windows and mac. Closes https://github.com/facebook/react-native/pull/6553 Differential Revision: D3075196 Pulled By: mkonicek fb-gh-sync-id: a19ab4030ec22d85bef40d7d91de53bc1da072ca shipit-source-id: a19ab4030ec22d85bef40d7d91de53bc1da072ca --- local-cli/util/Config.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/local-cli/util/Config.js b/local-cli/util/Config.js index 18785480c4b5ba..95ce3d4b11ff6a 100644 --- a/local-cli/util/Config.js +++ b/local-cli/util/Config.js @@ -33,8 +33,7 @@ const Config = { const parentDir = findParentDirectory(cwd, RN_CLI_CONFIG); if (!parentDir && !defaultConfig) { throw new Error( - 'Can\'t find "rn-cli.config.js" file in any parent folder of "' + - __dirname + '"' + `Can't find "rn-cli.config.js" file in any parent folder of "${__dirname}"` ); } @@ -63,7 +62,7 @@ function findParentDirectory(currentFullPath, filename) { return exists ? fullPath : testDir(parts.slice(0, -1)); }; - return testDir(currentFullPath.substring(1).split(path.sep)); + return testDir(currentFullPath.substring(root.length).split(path.sep)); } module.exports = Config;