Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

istanbul

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul - npm Package Compare versions

Comparing version 0.1.28 to 0.1.29

test/cli/sample-project/node_modules/post-require/package.json

20

lib/command/common/run-with-cover.js

@@ -19,2 +19,3 @@ /*

Report = require('../../report'),
resolve = require('resolve'),
DEFAULT_REPORT_FORMAT = 'lcov';

@@ -29,3 +30,3 @@

formatOption('--hook-run-in-context', 'hook vm.runInThisContext in addition to require (supports RequireJS), defaults to false'),
formatOption('--post-require-hook <file>', 'JS module that exports a function for post-require processing'),
formatOption('--post-require-hook <file> | <module>', 'JS module that exports a function for post-require processing'),
formatOption('--report <report-type>', 'report type, one of html, lcov, lcovonly, none, defaults to lcov (= lcov.info + HTML)'),

@@ -52,3 +53,3 @@ formatOption('--dir <report-dir>', 'report directory, defaults to ./coverage'),

'hook-run-in-context': Boolean,
'post-require-hook': path
'post-require-hook': String
},

@@ -127,9 +128,20 @@ opts = nopt(config, { v : '--verbose' }, args, 0),

hookOpts = { verbose: opts.verbose },
postRequireHook = opts['post-require-hook'],
postLoadHookFile;
if (opts['post-require-hook']) {
postLoadHookFile = path.resolve(opts['post-require-hook']);
if (postRequireHook) {
postLoadHookFile = path.resolve(postRequireHook);
} else if (opts.yui) { //EXPERIMENTAL code: do not rely on this in anyway until the docs say it is allowed
postLoadHookFile = path.resolve(__dirname, '../../util/yui-load-hook');
}
if (postRequireHook) {
if (!existsSync(postLoadHookFile)) { //assume it is a module name and resolve it
try {
postLoadHookFile = resolve.sync(postRequireHook, { basedir: process.cwd() });
} catch (ex) {
if (opts.verbose) { console.error('Unable to resolve [' + postRequireHook + '] as a node module'); }
}
}
}
if (postLoadHookFile) {

@@ -136,0 +148,0 @@ if (opts.verbose) { console.log('Use post-load-hook: ' + postLoadHookFile); }

{
"name": "istanbul",
"version": "0.1.28",
"version": "0.1.29",
"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",

@@ -34,3 +34,4 @@ "keywords": [ "coverage", "code coverage", "JS code coverage", "JS coverage" ],

"abbrev": "1.0.x",
"wordwrap": "0.0.x"
"wordwrap": "0.0.x",
"resolve": "0.2.x"
},

@@ -37,0 +38,0 @@ "devDependencies": {

23

test/cli/test-cover-command.js

@@ -128,3 +128,3 @@ /*jslint nomen: true */

},
"should apply post-require-hook correctly": function (test) {
"should apply post-require-hook correctly when absolute path specified": function (test) {
helper.setOpts({ lazyHook : true });

@@ -142,3 +142,24 @@ run([ 'test/run.js', '-v', '-x', '**/foo.js', '--post-require-hook', 'node_modules/post-require/hook.js' ], function (results) {

});
},
"should apply post-require-hook correctly when module name specified": function (test) {
helper.setOpts({ lazyHook : true });
run([ 'test/run.js', '-v', '-x', '**/foo.js', '--post-require-hook', 'post-require' ], function (results) {
test.ok(results.succeeded());
test.ok(results.grepError(/PRH: MatchFn was a function/));
test.ok(results.grepError(/PRH: TransformFn was a function/));
test.ok(results.grepError(/PRH: Verbose was true/));
//yes, post require hook must be called always even when a file is not covered
test.ok(results.grepError(/PRH: Saw foo\.js/));
//and, of course, for covered files as well
test.ok(results.grepError(/PRH: Saw bar\.js/));
test.done();
});
},
"should barf when post-require-hook not available": function (test) {
run([ 'test/run.js', '-v', '-x', '**/foo.js', '--post-require-hook', 'does-not-exist' ], function (results) {
test.ok(!results.succeeded());
test.ok(results.grepError(/Unable to resolve \[does-not-exist\] as a node module/));
test.done();
});
}
};
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc