UNPKG

dd-trace

Version:

Datadog APM tracing client for JavaScript

28 lines (23 loc) 714 B
'use strict' const shimmer = require('../../datadog-shimmer') const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper') const { addHook, channel } = require('./helpers/instrument') const codeCoverageWrapCh = channel('ci:nyc:wrap') addHook({ name: 'nyc', versions: ['>=17'] }, (nycPackage) => { // `wrap` is an async function shimmer.wrap(nycPackage.prototype, 'wrap', wrap => function () { // Only relevant if the config `all` is set to true try { if (JSON.parse(getEnvironmentVariable('NYC_CONFIG')).all) { codeCoverageWrapCh.publish(this) } } catch { // ignore errors } return wrap.apply(this, arguments) }) return nycPackage })