Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
fix: eslint package path for cache (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza authored and evilebottnawi committed Jul 4, 2019
1 parent bc2216e commit 8601da9
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions index.js
Expand Up @@ -160,21 +160,35 @@ module.exports = function(input, map) {
loaderUtils.getOptions(webpack)
);

var userEslintPath = userOptions.eslintPath;

var eslintPkgPath = "eslint/package.json";
if (userEslintPath) {
eslintPkgPath = userEslintPath + "/package.json";
var userEslintPath = eslintPkgPath;

if (userOptions.eslintPath) {
userEslintPath = userOptions.eslintPath + "/package.json";
}

var eslintVersion;

try {
eslintVersion = require(require.resolve(userEslintPath)).version;
} catch (_) {
// ignored
}

var eslintVersion = require(eslintPkgPath).version;
if (!eslintVersion) {
try {
eslintVersion = require(require.resolve(eslintPkgPath)).version;
} catch (_) {
// ignored
}
}

var config = assign(
// loader defaults
{
cacheIdentifier: JSON.stringify({
"eslint-loader": pkg.version,
eslint: eslintVersion
eslint: eslintVersion || "unknown version"
}),
eslintPath: "eslint"
},
Expand Down

0 comments on commit 8601da9

Please sign in to comment.