feat: add a global npmignore file#9351
Open
ljharb wants to merge 1 commit into
Open
Conversation
Defines a new path typed config, `global-ignore-file`, with a default of `${prefix}/etc/npmignore`.
The default is computed via a getter on the defaults object so it follows `--prefix` overrides, mirroring the existing `globalconfig` setup.
The default flatten function camelCases the key to `globalIgnoreFile`, which is the option name the pack and publish call chain will look for once `npm-packlist` and `pacote` ship matching support.
The intent is that a user can keep a single ignore list (for editor metadata, scratch directories, and similar artifacts that should never ship) instead of copying the same patterns into every package's `.npmignore`.
The patches that actually consume `globalIgnoreFile` live in `npm-packlist` and `pacote` and will land via separate releases of those packages.
Reserving the config name in cli now means once those releases land here, the value flows through without further changes.
Includes definitions tests (type, default, description, flattening), index tests (computed default from `--prefix`, explicit cli override), and updated snapshots for the type description, the config command output, and the docs generator.
e559d3e to
41a0eef
Compare
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.
The purpose of this is to allow users to specify files that should never be published that are not project-specific, and should remain on their local machine and NOT committed to every project they happen to work with. This could include IDE files (nobody else should know or care which IDE i'm using), LLM output (.claude directories, things like that), anything that is unique to me, my environment, or my machine, that i never want published.
The intention is for this global file to be configured in a user's npmrc, and then that separate file (
~/.npmignore, for example, like how most people's global gitignore is set to~/.gitignore) is respected.Whether a package is using
files, or.npmignore(or neither), the global npmignore is respected: withfiles, anything listed is published as normal; with.npmignoreor neither, anything listed (except things npm always publishes like package.json and the readme etc) will be removed from the packed file list.