Fix resolveNodeDependency for Windows

Summary:
Related to https://github.com/zalmoxisus/remote-redux-devtools/issues/62, we got the wrong resolved path on Windows, should use `path.sep` instead of `'/'`.
Closes https://github.com/facebook/react-native/pull/12206

Differential Revision: D4513338

fbshipit-source-id: 17814920986d091a6c6deae648f951f7be1cb688
This commit is contained in:
Jhen 2017-02-07 12:35:12 -08:00 committed by Facebook Github Bot
parent ab81db65c5
commit ee6adf817e
1 changed files with 3 additions and 3 deletions

View File

@ -316,10 +316,10 @@ class ResolutionRequest {
if (isRelativeImport(realModuleName) || isAbsolutePath(realModuleName)) {
// derive absolute path /.../node_modules/fromModuleDir/realModuleName
const fromModuleParentIdx = fromModule.path.lastIndexOf('node_modules/') + 13;
const fromModuleParentIdx = fromModule.path.lastIndexOf('node_modules' + path.sep) + 13;
const fromModuleDir = fromModule.path.slice(
0,
fromModule.path.indexOf('/', fromModuleParentIdx),
fromModule.path.indexOf(path.sep, fromModuleParentIdx),
);
const absPath = path.join(fromModuleDir, realModuleName);
return this._resolveFileOrDir(fromModule, absPath);
@ -339,7 +339,7 @@ class ResolutionRequest {
if (this._extraNodeModules) {
const {_extraNodeModules} = this;
const bits = toModuleName.split('/');
const bits = toModuleName.split(path.sep);
const packageName = bits[0];
if (_extraNodeModules[packageName]) {
bits[0] = _extraNodeModules[packageName];