mirror of https://github.com/status-im/metro.git
Fix the `path.sep` replacement of node-haste for Windows
Summary: Fix the `path.sep` replacement for Windows, currently it just replace one segment: ```js // Result: './lib/random\random-byte.js' './lib\\random\\random-byte.js'.replace(path.sep, '/') ``` Change to regex will work fine: ```js // Result: './lib/random/random-byte.js' (correct) './lib\\random\\random-byte.js'.replace(new RegExp('\\' + path.sep, 'g'), '/') ``` Closes https://github.com/facebook/react-native/pull/11641 Differential Revision: D4368402 fbshipit-source-id: 46f456359d1cd2ca790881773e8a76af8616cd21
This commit is contained in:
parent
8e9549fb2b
commit
033e7a0d6f
|
@ -77,7 +77,7 @@ module.exports = class Package {
|
||||||
|
|
||||||
let relPath = './' + path.relative(this.root, name);
|
let relPath = './' + path.relative(this.root, name);
|
||||||
if (path.sep !== '/') {
|
if (path.sep !== '/') {
|
||||||
relPath = relPath.replace(path.sep, '/');
|
relPath = relPath.replace(new RegExp('\\' + path.sep, 'g'), '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
let redirect = replacements[relPath];
|
let redirect = replacements[relPath];
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Package {
|
||||||
|
|
||||||
let relPath = './' + path.relative(this.root, name);
|
let relPath = './' + path.relative(this.root, name);
|
||||||
if (path.sep !== '/') {
|
if (path.sep !== '/') {
|
||||||
relPath = relPath.replace(path.sep, '/');
|
relPath = relPath.replace(new RegExp('\\' + path.sep, 'g'), '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
let redirect = replacements[relPath];
|
let redirect = replacements[relPath];
|
||||||
|
|
Loading…
Reference in New Issue