[BUG] `npm diff` expands filenames passed to it
Open
Nobody has claimed this yet.
Bug
cmd:diff
Priority 2
Release 7.x
Release 8.x
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Current Behavior:
$ npm diff --diff=<pkg-name> "index.esm.js"
npm appears to implicitly treat "index.esm.js" as if it ended in an asterisk / wildcard operator. It returns diffs for both index.esm.js (expected) and index.esm.js.map (not expected).
diff --git a/index.esm.js b/index.esm.js
index v0.0.0..v1.0.0
--- a/index.esm.js
+++ b/index.esm.js
[…]
diff --git a/index.esm.js.map b/index.esm.js.map
index v0.0.0..v1.0.0
--- a/index.esm.js.map
+++ b/index.esm.js.map
[…]
Expected Behavior:
$ npm diff --diff=<pkg-name> "index.esm.js"
diff --git a/index.esm.js b/index.esm.js
index v0.0.0..v1.0.0
--- a/index.esm.js
+++ b/index.esm.js
[…]
Steps To Reproduce:
Refer to the above console statements.
Environment:
- macOS 10.14.6
- Node.js v15.14.0
- npm@7.7.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior with the npm diff command shown, then trace the npm diff entry point to find where the filename argument is matched. The work is done when an exact filename returns only its own diff while broader matching behavior remains correct; add or update coverage if the relevant test location is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100