Skip to content

Commit ad2c064

Browse files
Enoah NetzachEnoahNetzach
Enoah Netzach
authored andcommitted
Honor only relative NODE_PATH
@see facebook#1194
1 parent 2a4fca6 commit ad2c064

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: packages/react-scripts/utils/createJestConfig.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
// Note: this file does not exist after ejecting.
1111

12-
const pathExists = require('path-exists');
12+
const fs = require('fs');
13+
const path = require('path');
1314
const paths = require('../config/paths');
1415

1516
module.exports = (resolve, rootDir, isEjecting) => {
1617
// Use this instead of `paths.testsSetup` to avoid putting
1718
// an absolute filename into configuration after ejecting.
18-
const setupTestsFile = pathExists.sync(paths.testsSetup) ? '<rootDir>/src/setupTests.js' : undefined;
19+
const setupTestsFile = fs.existsSync(paths.testsSetup) ? '<rootDir>/src/setupTests.js' : undefined;
1920

2021
// TODO: I don't know if it's safe or not to just use / as path separator
2122
// in Jest configs. We need help from somebody with Windows to determine this.
@@ -38,7 +39,9 @@ module.exports = (resolve, rootDir, isEjecting) => {
3839
transformIgnorePatterns: [
3940
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'
4041
],
41-
moduleDirectories: ['node_modules', process.env.NODE_PATH].filter(dir => dir),
42+
moduleDirectories: ['node_modules', process.env.NODE_PATH]
43+
.filter(dir => dir)
44+
.filter(folder => !path.isAbsolute(folder)),
4245
moduleNameMapper: {
4346
'^react-native$': 'react-native-web'
4447
}

0 commit comments

Comments
 (0)