Skip to content

Commit c532e56

Browse files
authored
Release 8.5.4 - Fix WSL/Windows paths (#350)
* fix FRONTIER-1135 handle Windows/WSL paths better * fix version
1 parent f9846b8 commit c532e56

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGELOG-FRONTIER.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 8.5.4
2+
3+
- Fix coalesceLocales to handle Windows/WSL paths correctly
4+
15
## 8.5.3
26

37
- Fix coalesceLocales to handle undefined paths better

packages/react-scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fs/react-scripts",
3-
"version": "8.5.3",
3+
"version": "8.5.4",
44
"upstreamVersion": "5.0.1",
55
"description": "Configuration and scripts for Create React App.",
66
"repository": {

packages/react-scripts/scripts/coalesceLocales.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,25 @@ exports.coalesceLocales = paths => {
3434
filter: filePath => filePath.includes(paths.appSrc) || filePath.includes('@fs'),
3535
}).sort();
3636

37+
/*
38+
REMINDER: when comparing paths, make sure to take into account Windows/WSL2 paths that will look like: 'C:\\Users\\MyUser\\my-project\\node_modules\\@fs\\flags-js\\src\\index.js'
39+
Constructing paths with forward slashes works, but not comparing the file path string, which needs to use `path.join()` or `path.sep`
40+
*/
41+
3742
// the nonExistents array is populated with any file that dependencyTree was unable to locate on the filesystem.
3843
// Currently we have an issue if npm didn't flatten a dependency to node_modules/@fs/ then dependencyTree says that
3944
// dependency is nonExistent. Specifically chinese-discovery-surname got into an issue once where zion-header wasn't
4045
// flattened, and so they didn't get zion-header translations coalesced. We are adding this globbing logic to go
4146
// find the least nested path to the "nonExistent" module.
42-
const hiddenNestedZionDeps = nonExistents.filter(filePath => filePath.startsWith('@fs/zion-'))
47+
const hiddenNestedZionDeps = nonExistents.filter(filePath => filePath.startsWith(path.join('@fs','zion-')))
4348
const hiddenNestedLocaleFiles = hiddenNestedZionDeps.map(filePath => {
4449
const hiddenLocaleFiles = glob.sync([`node_modules/@fs/**/${filePath}/**/locales/index.js`], { absolute: true })
45-
.filter(filePath => !filePath.includes('/cjs/'))
46-
return _.sortBy(hiddenLocaleFiles, filePath => filePath.split('/').length)[0]
50+
.filter(filePath => !filePath.includes(`${path.sep}cjs${path.sep}`))
51+
return _.sortBy(hiddenLocaleFiles, filePath => filePath.split(path.sep).length)[0]
4752
})
4853

4954
// adding this filter logic up in dependencyTree doesn't work as expected
50-
const realList = [...list.filter(filePath => filePath.includes('locales/index.js')), ...hiddenNestedLocaleFiles]
55+
const realList = [...list.filter(filePath => filePath.includes(path.join('locales','index.js'))), ...hiddenNestedLocaleFiles]
5156

5257
const allLocales = {};
5358
const collisionReport = {
@@ -60,7 +65,7 @@ exports.coalesceLocales = paths => {
6065
keys: new Set(),
6166
};
6267
realList.forEach(p => {
63-
if (!p) return
68+
if (!p) {return}
6469

6570
const dir = path.dirname(p);
6671
// console.log('dir', dir)

0 commit comments

Comments
 (0)