diff --git a/lib/store/fslookup.js b/lib/store/fslookup.js index b00cc179..06b00388 100644 --- a/lib/store/fslookup.js +++ b/lib/store/fslookup.js @@ -37,7 +37,8 @@ Store.mix(LookupStore, { return []; }, get: function (key) { - return fs.readFileSync(key, 'utf8'); + return sourceLookup(key) + // return fs.readFileSync(key, 'utf8'); }, hasKey: function (key) { var stats; @@ -59,3 +60,22 @@ Store.mix(LookupStore, { module.exports = LookupStore; +/* ====================================== */ + +/** + * fslookup patch + * + * @see https://github.com/vuejs/vue-loader/pull/1372 + */ +function sourceLookup (path) { + if (fs.existsSync(path)) { + return fs.readFileSync(path, 'utf8'); + } + if (/\.vue\.js$/.test(path)) { + const originalPath = path.substring(0, path.length - 3); + if (fs.existsSync(originalPath)) { + return fs.readFileSync(originalPath, 'utf8'); + } + } + throw new Error('Unable to lookup source: ' + path); +} diff --git a/package.json b/package.json index e0f02890..e627ba06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "macaca-istanbul", - "version": "1.0.5", + "version": "1.0.6", "description": "Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale", "keywords": [ "coverage",