diff --git a/lerna.json b/lerna.json index 9cababde742e..6c2fd7296e2e 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "lerna": "2.0.0-beta.24", + "lerna": "2.0.0-beta.26", "version": "14.1.3", "linkedFiles": { "prefix": "/**\n * @flow\n */\n" diff --git a/package.json b/package.json index 84d2b06e47ba..248112d9008b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "graceful-fs": "^4.1.5", "istanbul-api": "^1.0.0-aplha.10", "istanbul-lib-coverage": "^1.0.0", - "lerna": "2.0.0-beta.24", + "lerna": "2.0.0-beta.26", "minimatch": "^3.0.3", "mkdirp": "^0.5.1", "progress": "^1.1.8", @@ -28,7 +28,7 @@ "build-clean": "rm -rf ./packages/*/build", "build": "node ./scripts/build.js", "clean-all": "rm -rf ./packages/*/node_modules; rm -rf ./integration_tests/*/*/node_modules; npm run build-clean", - "jest": "./packages/jest-cli/bin/jest.js", + "jest": "node ./packages/jest-cli/bin/jest.js", "jest-coverage": "npm run jest -- --coverage", "lint": "eslint .", "postinstall": "node ./scripts/postinstall.js && node ./scripts/build.js", @@ -65,6 +65,6 @@ "\\.snap$", "packages/.*/build" ], - "testRegex": ".*-test.\\js" + "testRegex": ".*-test\\.js" } } diff --git a/packages/jest-cli/src/SearchSource.js b/packages/jest-cli/src/SearchSource.js index 683e64143381..40c8dc1a227c 100644 --- a/packages/jest-cli/src/SearchSource.js +++ b/packages/jest-cli/src/SearchSource.js @@ -86,9 +86,10 @@ class SearchSource { this._options = options || {}; this._testPathDirPattern = - new RegExp(config.testPathDirs.map(dir => { - return pathToRegex(utils.escapeStrForRegex(dir)); - }).join('|')); + new RegExp(config.testPathDirs.map( + dir => utils.escapePathForRegex(dir), + ).join('|')); + this._testRegex = new RegExp(pathToRegex(config.testRegex)); const ignorePattern = config.testPathIgnorePatterns; this._testIgnorePattern = diff --git a/packages/jest-util/src/index.js b/packages/jest-util/src/index.js index ba2b74c75e75..818c7b03a336 100644 --- a/packages/jest-util/src/index.js +++ b/packages/jest-util/src/index.js @@ -14,6 +14,15 @@ const fs = require('fs'); const mkdirp = require('mkdirp'); const path = require('path'); +const escapePathForRegex = (dir: string) => { + if (path.sep === '\\') { + // Replace "\" with "/" so it's not escaped by escapeStrForRegex. + // replacePathSepForRegex will convert it back. + dir = dir.replace(/\\/g, '/'); + } + return replacePathSepForRegex(escapeStrForRegex(dir)); +}; + const escapeStrForRegex = (string: string) => string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); @@ -57,6 +66,7 @@ exports.NullConsole = require('./NullConsole'); exports.clearLine = require('./clearLine'); exports.createDirectory = createDirectory; +exports.escapePathForRegex = escapePathForRegex; exports.escapeStrForRegex = escapeStrForRegex; exports.formatResultsErrors = require('./formatFailureMessage').formatResultsErrors;