-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Related to #25.
It'd be nice if the istanbul transformer also supported nyc, which in turn supports subprocesses. I got this working with the following voodoo, but I wasn't sure whether this was the supported mechanism per https://github.com/istanbuljs/nyc. Thoughts? Is this in scope?
function maybeCoverage() {
return Object.keys(require.cache).some((path) => /node_modules\/nyc/.test(path));
}
SandboxedModule.require('.../index.js', {
// Voodoo magic to support nyc.
sourceTransformers: maybeCoverage() ? {
nyc(source) {
const Instrumenter = require('nyc/lib/instrumenters/istanbul'),
instrumenter = Instrumenter(process.cwd(), {}),
instrumentMethod = instrumenter.instrumentSync.bind(instrumenter);
return instrumentMethod(source, this.filename);
}
} : {}
});mariecl
Metadata
Metadata
Assignees
Labels
No labels