CodeVetter · Repo Unpack · Data flow
istanbuljs/nyc
Arguments and project configuration become an NYC configuration object before child execution. Environment variables carry that configuration and ancestry into child processes, while loading hooks transform eligible source into counter-bearing code. Counters become coverage JSON and process metadata at exit. Report and merge operations read these artifacts, recover source maps, combine counters, and produce reports, merged JSON, or failure status.
- guessCWD() starts from its argument, NYC_CWD, or process.cwd(), searches upward for package.json, then processConfig() separates child arguments and passes nyc arguments to loadNycConfig().
- setupOptions() converts schema property names to dashed CLI names, carries defaults and aliases, treats arrays as string options, and hides options outside their declared command scope.
- The parent serializes argv into NYC_CONFIG and records process.cwd() in NYC_CWD; register-env snapshots selected variables and copies them into spawned environments.
- lib/wrap.js parses NYC_CONFIG, marks child execution, records pid/ppid/parent UUID, consumes an external process ID, and merges NYC_CONFIG_OVERRIDE before constructing NYC.
- Hooked code flows through _handleJs(), shouldInstrument(), extension lookup, caching-transform, and instrumentSync(); transform hashing includes filename metadata and a configuration/version salt.
- coverageFinder() obtains __coverage__; writeCoverageFile() removes excluded entries, attaches available content hashes when caching, serializes coverage, then saves matching process metadata.
- SourceMaps registers maps in memory or writes basename/hash .map cache files; coverage loading uses contentHash to reload maps and records failed map loads as false to avoid repeated reads.
- getCoverageMapFromAllCoverageFiles() reads directory entries with CPU-count concurrency, merges loaded reports, remaps coverage, and optionally filters afterward; report() renders that map and merge writes it as JSON.