Skip to content

Commit

Permalink
Fixes for building Jest on Windows. (#1463)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel15 authored and cpojer committed Aug 27, 2016
1 parent e588fc5 commit c447de1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -65,6 +65,6 @@
"\\.snap$",
"packages/.*/build"
],
"testRegex": ".*-test.\\js"
"testRegex": ".*-test\\.js"
}
}
7 changes: 4 additions & 3 deletions packages/jest-cli/src/SearchSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
10 changes: 10 additions & 0 deletions packages/jest-util/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '\\$&');

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c447de1

Please sign in to comment.