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
This commit is contained in:
Janic Duplessis 2016-03-20 18:08:23 -07:00 коммит произвёл Facebook Github Bot 1
Родитель b85f0ac74f
Коммит 4807290442
1 изменённых файлов: 2 добавлений и 3 удалений

Просмотреть файл

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