Socket
Socket
Sign inDemoInstall

istanbul-lib-report

Package Overview
Dependencies
5
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.2 to 2.0.3

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

<a name="2.0.3"></a>
## [2.0.3](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-report@2.0.2...istanbul-lib-report@2.0.3) (2018-12-25)
**Note:** Version bump only for package istanbul-lib-report
<a name="2.0.2"></a>

@@ -8,0 +16,0 @@ ## [2.0.2](https://github.com/istanbuljs/istanbuljs/compare/istanbul-lib-report@2.0.1...istanbul-lib-report@2.0.2) (2018-09-06)

8

index.js

@@ -5,3 +5,3 @@ /*

*/
"use strict";
'use strict';

@@ -22,3 +22,3 @@ /**

*/
createContext: function (opts) {
createContext: function(opts) {
return context.create(opts);

@@ -33,3 +33,3 @@ },

*/
getDefaultWatermarks: function () {
getDefaultWatermarks: function() {
return watermarks.getDefault();

@@ -60,3 +60,1 @@ }

};

@@ -15,3 +15,5 @@ /*

} catch (ex) {
throw new Error('Unable to lookup source: ' + path + '(' + ex.message + ')');
throw new Error(
'Unable to lookup source: ' + path + '(' + ex.message + ')'
);
}

@@ -22,5 +24,7 @@ }

specified = specified || {};
Object.keys(defaults).forEach(function (k) {
Object.keys(defaults).forEach(function(k) {
var specValue = specified[k];
if (!(specValue && Array.isArray(specValue) && specValue.length === 2)) {
if (
!(specValue && Array.isArray(specValue) && specValue.length === 2)
) {
specified[k] = defaults[k];

@@ -52,3 +56,3 @@ }

enumerable: true,
get: function () {
get: function() {
if (!this.data.writer) {

@@ -66,3 +70,3 @@ this.data.writer = new FileWriter(this.dir);

*/
Context.prototype.getWriter = function () {
Context.prototype.getWriter = function() {
return this.writer;

@@ -77,3 +81,3 @@ };

*/
Context.prototype.getSource = function (filePath) {
Context.prototype.getSource = function(filePath) {
return this.sourceFinder(filePath);

@@ -90,3 +94,3 @@ };

*/
Context.prototype.classForPercent = function (type, value) {
Context.prototype.classForPercent = function(type, value) {
var watermarks = this.watermarks[type];

@@ -110,3 +114,3 @@ if (!watermarks) {

*/
Context.prototype.getXMLWriter = function (contentWriter) {
Context.prototype.getXMLWriter = function(contentWriter) {
return new XMLWriter(contentWriter);

@@ -121,3 +125,3 @@ };

*/
Context.prototype.getVisitor = function (partialVisitor) {
Context.prototype.getVisitor = function(partialVisitor) {
return new tree.Visitor(partialVisitor);

@@ -127,5 +131,5 @@ };

module.exports = {
create: function (opts) {
create: function(opts) {
return new Context(opts);
}
};

@@ -10,3 +10,5 @@ /*

supportsColor = require('supports-color'),
isAbsolute = path.isAbsolute || /* istanbul ignore next */ function (p) {
isAbsolute =
path.isAbsolute ||
/* istanbul ignore next */ function(p) {
return path.resolve(p) === path.normalize(p);

@@ -21,4 +23,3 @@ };

/* istanbul ignore next: abstract class */
function ContentWriter() {
}
function ContentWriter() {}

@@ -30,3 +31,3 @@ /**

/* istanbul ignore next: abstract class */
ContentWriter.prototype.write = function () {
ContentWriter.prototype.write = function() {
throw new Error('write: must be overridden');

@@ -44,3 +45,3 @@ };

*/
ContentWriter.prototype.colorize = function (str /*, clazz*/) {
ContentWriter.prototype.colorize = function(str /*, clazz*/) {
return str;

@@ -53,3 +54,3 @@ };

*/
ContentWriter.prototype.println = function (str) {
ContentWriter.prototype.println = function(str) {
this.write(str + '\n');

@@ -61,4 +62,3 @@ };

*/
ContentWriter.prototype.close = function () {
};
ContentWriter.prototype.close = function() {};

@@ -76,7 +76,7 @@ /**

FileContentWriter.prototype.write = function (str) {
FileContentWriter.prototype.write = function(str) {
fs.writeSync(this.fd, str);
};
FileContentWriter.prototype.close = function () {
FileContentWriter.prototype.close = function() {
fs.closeSync(this.fd);

@@ -90,4 +90,3 @@ };

*/
function ConsoleWriter() {
}
function ConsoleWriter() {}
util.inherits(ConsoleWriter, ContentWriter);

@@ -98,3 +97,3 @@

var output = '';
ConsoleWriter.prototype.write = function (str) {
ConsoleWriter.prototype.write = function(str) {
if (capture) {

@@ -107,3 +106,3 @@ output += str;

ConsoleWriter.prototype.colorize = function (str, clazz) {
ConsoleWriter.prototype.colorize = function(str, clazz) {
var colors = {

@@ -136,16 +135,16 @@ low: '31;1',

/**
* static helpers for capturing stdout report output;
* super useful for tests!
*/
FileWriter.startCapture = function () {
capture = true;
* static helpers for capturing stdout report output;
* super useful for tests!
*/
FileWriter.startCapture = function() {
capture = true;
};
FileWriter.stopCapture = function () {
capture = false;
FileWriter.stopCapture = function() {
capture = false;
};
FileWriter.getOutput = function () {
return output;
FileWriter.getOutput = function() {
return output;
};
FileWriter.resetOutput = function () {
output = '';
FileWriter.resetOutput = function() {
output = '';
};

@@ -159,5 +158,7 @@

*/
FileWriter.prototype.writerForDir = function (subdir) {
FileWriter.prototype.writerForDir = function(subdir) {
if (isAbsolute(subdir)) {
throw new Error('Cannot create subdir writer for absolute path: ' + subdir);
throw new Error(
'Cannot create subdir writer for absolute path: ' + subdir
);
}

@@ -173,3 +174,3 @@ return new FileWriter(this.baseDir + '/' + subdir);

*/
FileWriter.prototype.copyFile = function (source, dest, header) {
FileWriter.prototype.copyFile = function(source, dest, header) {
if (isAbsolute(dest)) {

@@ -188,3 +189,3 @@ throw new Error('Cannot write to absolute path: ' + dest);

*/
FileWriter.prototype.writeFile = function (file) {
FileWriter.prototype.writeFile = function(file) {
if (file === null || file === '-') {

@@ -191,0 +192,0 @@ return new ConsoleWriter();

@@ -5,3 +5,3 @@ /*

*/
"use strict";
'use strict';

@@ -46,3 +46,3 @@ var path = require('path'),

}
if (dir.substring(0,1) === '/') {
if (dir.substring(0, 1) === '/') {
dir = dir.substring(1);

@@ -57,18 +57,20 @@ }

this.v = strOrArray;
} else if (typeof strOrArray === "string") {
} else if (typeof strOrArray === 'string') {
this.v = makeRelativeNormalizedPath(strOrArray, SEP);
} else {
throw new Error('Invalid Path argument must be string or array:' + strOrArray);
throw new Error(
'Invalid Path argument must be string or array:' + strOrArray
);
}
}
Path.prototype.toString = function () {
Path.prototype.toString = function() {
return this.v.join('/');
};
Path.prototype.hasParent = function () {
Path.prototype.hasParent = function() {
return this.v.length > 0;
};
Path.prototype.parent = function () {
Path.prototype.parent = function() {
if (!this.hasParent()) {

@@ -82,7 +84,7 @@ throw new Error('Unable to get parent for 0 elem path');

Path.prototype.elements = function () {
Path.prototype.elements = function() {
return this.v.slice();
};
Path.prototype.contains = function (other) {
Path.prototype.contains = function(other) {
var i;

@@ -100,11 +102,11 @@ if (other.length > this.length) {

Path.prototype.ancestorOf = function (other) {
Path.prototype.ancestorOf = function(other) {
return other.contains(this) && other.length !== this.length;
};
Path.prototype.descendantOf = function (other) {
Path.prototype.descendantOf = function(other) {
return this.contains(other) && other.length !== this.length;
};
Path.prototype.commonPrefixPath = function (other) {
Path.prototype.commonPrefixPath = function(other) {
var len = this.length > other.length ? other.length : this.length,

@@ -114,3 +116,3 @@ i,

for (i = 0; i < len; i +=1 ) {
for (i = 0; i < len; i += 1) {
if (this.v[i] === other.v[i]) {

@@ -125,4 +127,4 @@ ret.push(this.v[i]);

['push', 'pop', 'shift', 'unshift', 'splice'].forEach(function (f) {
Path.prototype[f] = function () {
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(function(f) {
Path.prototype[f] = function() {
var args = Array.prototype.slice.call(arguments),

@@ -134,3 +136,3 @@ v = this.v;

Path.compare = function (a, b) {
Path.compare = function(a, b) {
var al = a.length,

@@ -153,3 +155,3 @@ bl = b.length,

enumerable: true,
get: function () {
get: function() {
return this.v.length;

@@ -161,7 +163,7 @@ }

Path.tester = {
setParserAndSep: function (p, sep) {
setParserAndSep: function(p, sep) {
parsePath = p;
SEP = sep;
},
reset: function () {
reset: function() {
parsePath = origParser;

@@ -171,2 +173,1 @@ SEP = origSep;

};

@@ -5,3 +5,3 @@ /*

*/
"use strict";
'use strict';

@@ -24,3 +24,3 @@ var Path = require('./path'),

ReportNode.prototype.addChild = function (child) {
ReportNode.prototype.addChild = function(child) {
child.parent = this;

@@ -30,5 +30,5 @@ this.children.push(child);

ReportNode.prototype.asRelative = function (p) {
ReportNode.prototype.asRelative = function(p) {
/* istanbul ignore if */
if (p.substring(0,1) === '/') {
if (p.substring(0, 1) === '/') {
return p.substring(1);

@@ -39,7 +39,7 @@ }

ReportNode.prototype.getQualifiedName = function () {
ReportNode.prototype.getQualifiedName = function() {
return this.asRelative(this.path.toString());
};
ReportNode.prototype.getRelativeName = function () {
ReportNode.prototype.getRelativeName = function() {
var parent = this.getParent(),

@@ -60,19 +60,19 @@ myPath = this.path,

ReportNode.prototype.getParent = function () {
ReportNode.prototype.getParent = function() {
return this.parent;
};
ReportNode.prototype.getChildren = function () {
ReportNode.prototype.getChildren = function() {
return this.children;
};
ReportNode.prototype.isSummary = function () {
ReportNode.prototype.isSummary = function() {
return !this.fileCoverage;
};
ReportNode.prototype.getFileCoverage = function () {
ReportNode.prototype.getFileCoverage = function() {
return this.fileCoverage;
};
ReportNode.prototype.getCoverageSummary = function (filesOnly) {
ReportNode.prototype.getCoverageSummary = function(filesOnly) {
var cacheProp = 'c_' + (filesOnly ? 'files' : 'full'),

@@ -90,3 +90,3 @@ summary;

summary = coverage.createCoverageSummary();
this.getChildren().forEach(function (child) {
this.getChildren().forEach(function(child) {
if (filesOnly && child.isSummary()) {

@@ -109,3 +109,3 @@ return;

visitor,
maybePrefix = function (node) {
maybePrefix = function(node) {
if (childPrefix && !node.isRoot()) {

@@ -115,15 +115,19 @@ node.path.unshift(childPrefix);

};
tree.getRoot = function () {
tree.getRoot = function() {
return root;
};
visitor = {
onDetail: function (node) {
onDetail: function(node) {
maybePrefix(node);
},
onSummary: function (node) {
onSummary: function(node) {
maybePrefix(node);
node.children.sort(function (a, b) {
node.children.sort(function(a, b) {
var astr = a.path.toString(),
bstr = b.path.toString();
return astr < bstr ? -1 : astr > bstr ? 1: /* istanbul ignore next */ 0;
return astr < bstr
? -1
: astr > bstr
? 1
: /* istanbul ignore next */ 0;
});

@@ -155,3 +159,3 @@ }

commonParent;
coverageMap.files().forEach(function (filePath) {
coverageMap.files().forEach(function(filePath) {
var p = new Path(filePath),

@@ -165,5 +169,9 @@ coverage = coverageMap.fileCoverageFor(filePath);

});
commonParent = findCommonParent(ret.map(function (o) { return o.path.parent(); }));
commonParent = findCommonParent(
ret.map(function(o) {
return o.path.parent();
})
);
if (commonParent.length > 0) {
ret.forEach(function (o) {
ret.forEach(function(o) {
o.path.splice(0, commonParent.length);

@@ -181,3 +189,3 @@ });

parentNodeList = [];
list.forEach(function (o) {
list.forEach(function(o) {
var node = new ReportNode(o.path, o.fileCoverage),

@@ -198,7 +206,9 @@ parentPath = o.path.parent(),

function foldIntoParents(nodeList) {
var ret = [], i, j;
var ret = [],
i,
j;
// sort by longest length first
nodeList.sort(function (a, b) {
return -1 * Path.compare(a.path , b.path);
nodeList.sort(function(a, b) {
return -1 * Path.compare(a.path, b.path);
});

@@ -245,3 +255,3 @@

root = createRoot();
topNodes.forEach(function (node) {
topNodes.forEach(function(node) {
root.addChild(node);

@@ -265,6 +275,6 @@ });

// then we need to create a top-level dir
dirParents.forEach(function (dp) {
if (dp.path.length === 0) {
prefix = 'root';
}
dirParents.forEach(function(dp) {
if (dp.path.length === 0) {
prefix = 'root';
}
});

@@ -274,3 +284,3 @@ if (prefix && common.length > 0) {

}
dirParents.forEach(function (node) {
dirParents.forEach(function(node) {
root.addChild(node);

@@ -288,3 +298,3 @@ });

root = createRoot();
list.forEach(function (o) {
list.forEach(function(o) {
var node = new ReportNode(o.path, o.fileCoverage);

@@ -297,5 +307,5 @@ root.addChild(node);

module.exports = {
createNestedSummary: createNestedSummary,
createNestedSummary: createNestedSummary,
createPackageSummary: createPackageSummary,
createFlatSummary: createFlatSummary
};

@@ -5,3 +5,3 @@ /*

*/
"use strict";
'use strict';

@@ -31,5 +31,5 @@ var util = require('util');

['Start', 'End', 'Summary', 'SummaryEnd', 'Detail' ].forEach(function (k) {
['Start', 'End', 'Summary', 'SummaryEnd', 'Detail'].forEach(function(k) {
var f = 'on' + k;
Visitor.prototype[f] = function (node, state) {
Visitor.prototype[f] = function(node, state) {
if (this.delegate[f] && typeof this.delegate[f] === 'function') {

@@ -45,3 +45,3 @@ this.delegate[f].call(this.delegate, node, state);

}
this.visitors = visitors.map(function (v) {
this.visitors = visitors.map(function(v) {
if (v instanceof Visitor) {

@@ -56,6 +56,6 @@ return v;

['Start', 'Summary', 'SummaryEnd', 'Detail', 'End'].forEach(function (k) {
['Start', 'Summary', 'SummaryEnd', 'Detail', 'End'].forEach(function(k) {
var f = 'on' + k;
CompositeVisitor.prototype[f] = function (node, state) {
this.visitors.forEach(function (v) {
CompositeVisitor.prototype[f] = function(node, state) {
this.visitors.forEach(function(v) {
v[f](node, state);

@@ -66,7 +66,6 @@ });

function Node() {
}
function Node() {}
/* istanbul ignore next: abstract method */
Node.prototype.getQualifiedName = function () {
Node.prototype.getQualifiedName = function() {
throw new Error('getQualifiedName must be overridden');

@@ -76,3 +75,3 @@ };

/* istanbul ignore next: abstract method */
Node.prototype.getRelativeName = function () {
Node.prototype.getRelativeName = function() {
throw new Error('getRelativeName must be overridden');

@@ -82,3 +81,3 @@ };

/* istanbul ignore next: abstract method */
Node.prototype.isRoot = function () {
Node.prototype.isRoot = function() {
return !this.getParent();

@@ -88,3 +87,3 @@ };

/* istanbul ignore next: abstract method */
Node.prototype.getParent = function () {
Node.prototype.getParent = function() {
throw new Error('getParent must be overridden');

@@ -94,3 +93,3 @@ };

/* istanbul ignore next: abstract method */
Node.prototype.getChildren = function () {
Node.prototype.getChildren = function() {
throw new Error('getChildren must be overridden');

@@ -100,3 +99,3 @@ };

/* istanbul ignore next: abstract method */
Node.prototype.isSummary = function () {
Node.prototype.isSummary = function() {
throw new Error('isSummary must be overridden');

@@ -106,3 +105,3 @@ };

/* istanbul ignore next: abstract method */
Node.prototype.getCoverageSummary = function (/* filesOnly */) {
Node.prototype.getCoverageSummary = function(/* filesOnly */) {
throw new Error('getCoverageSummary must be overridden');

@@ -112,3 +111,3 @@ };

/* istanbul ignore next: abstract method */
Node.prototype.getFileCoverage = function () {
Node.prototype.getFileCoverage = function() {
throw new Error('getFileCoverage must be overridden');

@@ -123,7 +122,6 @@ };

*/
Node.prototype.visit = function (visitor, state) {
Node.prototype.visit = function(visitor, state) {
var that = this,
visitChildren = function () {
that.getChildren().forEach(function (child) {
visitChildren = function() {
that.getChildren().forEach(function(child) {
child.visit(visitor, state);

@@ -150,4 +148,3 @@ });

*/
function Tree() {
}
function Tree() {}

@@ -158,3 +155,3 @@ /**

/* istanbul ignore next: abstract method */
Tree.prototype.getRoot = function () {
Tree.prototype.getRoot = function() {
throw new Error('getRoot must be overridden');

@@ -168,3 +165,3 @@ };

*/
Tree.prototype.visit = function (visitor, state) {
Tree.prototype.visit = function(visitor, state) {
if (!(visitor instanceof Visitor)) {

@@ -171,0 +168,0 @@ visitor = new Visitor(visitor);

@@ -6,3 +6,3 @@ /*

module.exports = {
getDefault: function () {
getDefault: function() {
return {

@@ -9,0 +9,0 @@ statements: [50, 80],

@@ -22,3 +22,3 @@ /*

var ret = [];
Object.keys(attrs).forEach(function (k) {
Object.keys(attrs).forEach(function(k) {
var v = attrs[k];

@@ -30,4 +30,10 @@ ret.push(k + '="' + v + '"');

XMLWriter.prototype.indent = function (str) {
return this.stack.map(function () { return INDENT; }).join('') + str;
XMLWriter.prototype.indent = function(str) {
return (
this.stack
.map(function() {
return INDENT;
})
.join('') + str
);
};

@@ -40,3 +46,3 @@

*/
XMLWriter.prototype.openTag = function (name, attrs) {
XMLWriter.prototype.openTag = function(name, attrs) {
var str = this.indent('<' + name + attrString(attrs) + '>');

@@ -52,3 +58,3 @@ this.cw.println(str);

*/
XMLWriter.prototype.closeTag = function (name) {
XMLWriter.prototype.closeTag = function(name) {
if (this.stack.length === 0) {

@@ -61,3 +67,9 @@ throw new Error('Attempt to close tag ' + name + ' when not opened');

if (stashed !== name) {
throw new Error('Attempt to close tag ' + name + ' when ' + stashed + ' was the one open');
throw new Error(
'Attempt to close tag ' +
name +
' when ' +
stashed +
' was the one open'
);
}

@@ -72,3 +84,3 @@ this.cw.println(this.indent(str));

*/
XMLWriter.prototype.inlineTag = function (name, attrs, content) {
XMLWriter.prototype.inlineTag = function(name, attrs, content) {
var str = '<' + name + attrString(attrs);

@@ -86,9 +98,12 @@ if (content) {

*/
XMLWriter.prototype.closeAll = function () {
XMLWriter.prototype.closeAll = function() {
var that = this;
this.stack.slice().reverse().forEach(function (name) {
that.closeTag(name);
});
this.stack
.slice()
.reverse()
.forEach(function(name) {
that.closeTag(name);
});
};
module.exports = XMLWriter;
{
"name": "istanbul-lib-report",
"version": "2.0.2",
"version": "2.0.3",
"description": "Base reporting library for istanbul",

@@ -12,7 +12,6 @@ "author": "Krishnan Anantheswaran <kananthmail-github@yahoo.com>",

"scripts": {
"pretest": "jshint index.js lib/ test/",
"test": "mocha"
},
"dependencies": {
"istanbul-lib-coverage": "^2.0.1",
"istanbul-lib-coverage": "^2.0.2",
"make-dir": "^1.3.0",

@@ -24,3 +23,2 @@ "supports-color": "^5.4.0"

"istanbul": "^0.4.5",
"jshint": "^2.9.5",
"mocha": "^5.2.0",

@@ -27,0 +25,0 @@ "rimraf": "^2.6.2"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc