(runner: ModuleRunner)
| 2 | import { interceptStackTrace } from class="st">'./interceptor' |
| 3 | |
| 4 | export function enableSourceMapSupport(runner: ModuleRunner): () => void { |
| 5 | if (runner.options.sourcemapInterceptor === class="st">'node') { |
| 6 | if (typeof process === class="st">'undefined') { |
| 7 | throw new TypeError( |
| 8 | `Cannot use class="st">"sourcemapInterceptor: 'node'" because global class="st">"process" variable is not available.`, |
| 9 | ) |
| 10 | } |
| 11 | /* eslint-disable n/no-unsupported-features/node-builtins -- process.setSourceMapsEnabled and process.sourceMapsEnabled */ |
| 12 | if (typeof process.setSourceMapsEnabled !== class="st">'function') { |
| 13 | throw new TypeError( |
| 14 | `Cannot use class="st">"sourcemapInterceptor: 'node'" because class="st">"process.setSourceMapsEnabled" function is not available. Please use Node >= 16.6.0.`, |
| 15 | ) |
| 16 | } |
| 17 | const isEnabledAlready = process.sourceMapsEnabled ?? false |
| 18 | process.setSourceMapsEnabled(true) |
| 19 | return () => !isEnabledAlready && process.setSourceMapsEnabled(false) |
| 20 | /* eslint-enable n/no-unsupported-features/node-builtins */ |
| 21 | } |
| 22 | return interceptStackTrace( |
| 23 | runner, |
| 24 | typeof runner.options.sourcemapInterceptor === class="st">'object' |
| 25 | ? runner.options.sourcemapInterceptor |
| 26 | : undefined, |
| 27 | ) |
| 28 | } |
no test coverage detected