Merge pull request babel/babel-eslint#135 from PiPeep/fix-jest

Fix eslint module path resolution in jest
This commit is contained in:
Henry Zhu
2015-06-23 18:32:09 -04:00
parent c22414c1fd
commit 7ff5dd56e8

View File

@@ -22,9 +22,15 @@ function monkeypatch() {
var eslintLoc;
try {
// avoid importing a local copy of eslint, try to find a peer dependency
eslintLoc = Module._resolveFilename("eslint", module.parent);
} catch (err) {
throw new ReferenceError("couldn't resolve eslint");
try {
// avoids breaking in jest where module.parent is undefined
eslintLoc = require.resolve("eslint");
} catch (err) {
throw new ReferenceError("couldn't resolve eslint");
}
}
// get modules relative to what eslint will load