istanbul-lib-source-maps
Advanced tools
| var path = require('path'), | ||
| isAbsolute = function (p) { | ||
| if (path.isAbsolute) { | ||
| return path.isAbsolute(p); | ||
| } | ||
| return path.resolve(p) === path.normalize(p); | ||
| }; | ||
| exports.isAbsolute = isAbsolute; | ||
| exports.asAbsolute = function (file, baseDir) { | ||
| return isAbsolute(file) ? file : path.resolve(baseDir || process.cwd, file); | ||
| }; | ||
| exports.relativeTo = function (file, origFile) { | ||
| return isAbsolute(file) ? file : path.resolve(path.dirname(origFile), file); | ||
| }; |
+7
-11
@@ -9,8 +9,3 @@ /* | ||
| fs = require('fs'), | ||
| isAbsolute = function (p) { | ||
| if (path.isAbsolute) { | ||
| return path.isAbsolute(p); | ||
| } | ||
| return path.resolve(p) === path.normalize(p); | ||
| }, | ||
| pathutils = require('./pathutils'), | ||
| sourceStore = require('./source-store'), | ||
@@ -64,3 +59,3 @@ transformer = require('./transformer'), | ||
| } | ||
| var dir = path.dirname(transformedFilePath), | ||
| var dir = path.dirname(path.resolve(transformedFilePath)), | ||
| file = path.resolve(dir, sourceMapUrl); | ||
@@ -100,6 +95,6 @@ this.data[transformedFilePath] = { type: 'file', data: file }; | ||
| } | ||
| if (isAbsolute(filePath)) { | ||
| if (pathutils.isAbsolute(filePath)) { | ||
| return fs.readFileSync(filePath, 'utf8'); | ||
| } | ||
| return fs.readFileSync(path.resolve(that.baseDir || process.cwd(), filePath), 'utf8'); | ||
| return fs.readFileSync(pathutils.asAbsolute(filePath, that.baseDir)); | ||
| }; | ||
@@ -131,5 +126,6 @@ | ||
| smc.sources.forEach(function (s) { | ||
| var content = smc.sourceContentFor(s); | ||
| var content = smc.sourceContentFor(s), | ||
| sourceFilePath = pathutils.relativeTo(s, filePath); | ||
| if (content) { | ||
| that.sourceStore.registerSource(s, content); | ||
| that.sourceStore.registerSource(sourceFilePath, content); | ||
| } | ||
@@ -136,0 +132,0 @@ }); |
@@ -7,3 +7,4 @@ /* | ||
| var libCoverage = require('istanbul-lib-coverage'), | ||
| var pathutils = require('./pathutils'), | ||
| libCoverage = require('istanbul-lib-coverage'), | ||
| MappedCoverage = require('./mapped').MappedCoverage; | ||
@@ -17,3 +18,3 @@ | ||
| */ | ||
| function getMapping(sourceMap, location) { | ||
| function getMapping(sourceMap, location, origFile) { | ||
@@ -53,3 +54,3 @@ var start = sourceMap.originalPositionFor(location.start), | ||
| return { | ||
| source: start.source, | ||
| source: pathutils.relativeTo(start.source, origFile), | ||
| loc: { | ||
@@ -80,3 +81,3 @@ start: { | ||
| hits = fc.s[s], | ||
| mapping = getMapping(sourceMap, loc), | ||
| mapping = getMapping(sourceMap, loc, fc.path), | ||
| mappedCoverage; | ||
@@ -94,4 +95,4 @@ | ||
| hits = fc.f[f], | ||
| mapping = getMapping(sourceMap, fnMeta.decl), | ||
| spanMapping = getMapping(sourceMap, fnMeta.loc), | ||
| mapping = getMapping(sourceMap, fnMeta.decl, fc.path), | ||
| spanMapping = getMapping(sourceMap, fnMeta.loc, fc.path), | ||
| mappedCoverage; | ||
@@ -117,3 +118,3 @@ | ||
| for (i = 0; i < branchMeta.locations.length; i += 1) { | ||
| mapping = getMapping(sourceMap, branchMeta.locations[i]); | ||
| mapping = getMapping(sourceMap, branchMeta.locations[i], fc.path); | ||
| if (mapping) { | ||
@@ -120,0 +121,0 @@ if (!source) { |
+1
-1
| { | ||
| "name": "istanbul-lib-source-maps", | ||
| "version": "1.0.0-alpha.8", | ||
| "version": "1.0.0-alpha.9", | ||
| "description": "Source maps support for istanbul", | ||
@@ -5,0 +5,0 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
59054
0.99%16
6.67%1555
0.71%