felixge / felixge/node-sandboxed-module
nyc builtin source transformer
- 主要语言
- JavaScript
- 星标
- 343
- 派生
- 41
- PR 合并指标
- 30 天内没有已合并 PR
描述
Related to https://github.com/felixge/node-sandboxed-module/issues/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?
```js
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);
}
} : {}
});
```
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。