Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Fix cli config file on Windows
Browse files Browse the repository at this point in the history
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  facebook#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 facebook#6553

Differential Revision: D3075196

Pulled By: mkonicek

fb-gh-sync-id: a19ab4030ec22d85bef40d7d91de53bc1da072ca
shipit-source-id: a19ab4030ec22d85bef40d7d91de53bc1da072ca
  • Loading branch information
janicduplessis authored and Facebook Github Bot 1 committed Mar 21, 2016
1 parent b85f0ac commit 4807290
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions local-cli/util/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`
);
}

Expand Down Expand Up @@ -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;

0 comments on commit 4807290

Please sign in to comment.