Repository navigation
docs: warn against nyc instrument --in-place (#861) - #1010
Merged
Merged
Conversation
`nyc instrument --in-place` overwrites the source files with instrumented code. The HTML reporter reads sources from disk, so the report then shows instrumented code. Recommend instrumenting into a separate folder instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WUv8r4ToKpF6R8iwcic9CU
|
🎉 This PR is included in version 4.1.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional details
nyc instrument --in-placeoverwrites source files with instrumented code. The HTML reporter (nyc.report()inlib/task.ts) reads source files from disk, so the report shows instrumented code. This is expectednycbehavior, not a plugin bug.This adds one paragraph to the "Instrument your application" section of
README.md. It recommends writingnyc instrumentoutput to a separate folder (for example,nyc instrument src dist-instrumented) and explains why--in-placebreaks the report. No code changes.How I checked it: I instrumented the same file both ways and generated the HTML report with
nyc.report(). Both runs record the same coverage key (src/math.js). The--in-placereport shows instrumented code, and the separate-folder report shows the original source.Steps to test
README.md.nyc instrument --in-place srcon a sample file, run the code, then runnyc report --reporter=htmland confirm the report shows instrumented code. Repeat withnyc instrument src dist-instrumentedand confirm the report shows the original source.How has the user experience changed?
No change. This is a docs-only update.
Generated by Claude Code
Note
Low Risk
Documentation-only change with no runtime or configuration impact.
Overview
Adds guidance in Instrument your application for teams that pre-instrument with
nyc instrument: write output to a separate directory (e.g.nyc instrument src dist-instrumented) and serve that build, and avoid--in-place.The new paragraph explains that in-place instrumentation overwrites sources on disk, and because HTML coverage reports (via the plugin’s
nyc.report()flow) show whatever is on disk, reports would display instrumented boilerplate instead of readable source—clarifying expectednycbehavior rather than a plugin defect. Closes #861.Reviewed by Cursor Bugbot for commit 259a09a. Bugbot is set up for automated code reviews on this repo. Configure here.