Skip to content

Commit

Permalink
Honor only relative NODE_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
Enoah Netzach authored and EnoahNetzach committed Jan 19, 2017
1 parent 2a4fca6 commit ad2c064
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/react-scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

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

const pathExists = require('path-exists');
const fs = require('fs');
const path = require('path');
const paths = require('../config/paths');

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

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

0 comments on commit ad2c064

Please sign in to comment.