CodeVetter · Repo Unpack · Extension points
istanbuljs/nyc
Extensions enter through command modules, schema-derived options, configuration presets, preloaded modules, instrumenter factories, and reporter factories. NYC already centralizes the selection and transform pipeline, so additions should reuse those boundaries. Some extension contracts depend on external packages rather than a repository-local registry. Command dispatch and cache invalidation require coordinated changes across multiple files.
- A command module exports command, describe, builder, and handler; adding a command requires coordinating yargs registration, process-args' recognized command list, and bin/nyc.js' early-return list.
- CLI options are derived from schema.nyc.properties through setupOptions(); coverageVariable and global-scope options are explicitly blocked because they are not connected to the instrumenter.
- Reusable configurations use extends and can be exported as JSON or JavaScript npm modules; processConfig() delegates configuration loading to @istanbuljs/load-nyc-config.
- The instrumenter factory receives ignoreClassMethods, source-map production, compactness, comments, ESM parsing, and parser plugins; built-in adapters expose instrumentSync() and lastFileCoverage().
- Additional extensions receive entries in the transforms table and hook registration; addAllFiles() can obtain transpiled source through Module._extensions, falling back to the .js loader when an extension is unknown.
- --require is the module-setup extension point, with resolution attempted relative to NYC.cwd before fallback; non-spawn-wrap startup places these modules before lib/wrap.js in the preload list.
- Reporter names are stored as an array and passed to istanbul-reports.create(); README documents built-in reporters and npm package reporters, with per-reporter presentation options passed at execution.
- Instrumentation cache behavior has explicit extension-sensitive hooks: _createTransform() chooses eager or lazy factories, records hashes by filename, and Hash.salt() includes package versions and selected configuration values.