Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Here's a puzzle to noodle on:

Let's say package.json contains this:

{
  "files": [
    "lib",
    "!lib/one",
    "lib/two"
  ]
}

Files in lib/ are: .npmignore, one, two, tre

The file at lib/.npmignore contains:

two

Which files will be included in the package?

  • 🅰️: lib/two, lib/tre, package.json
  • 🅱️: lib/tre, lib/.npmignore, package.json

(Please don't look it up, the point of the exercise is to gauge expectations.)

@isaacs

This comment has been minimized.

Copy link
Owner Author

isaacs commented Oct 9, 2019

Argument for 🅰️:

The package.json file specifies what files are to be included. This supersedes any ignore files found throughout the tree.

Argument for 🅱️:

There's an ignore file right there! It says to ignore two, so two should be ignored.

@isaacs

This comment has been minimized.

Copy link
Owner Author

isaacs commented Oct 11, 2019

@PatrickQuintal

This comment has been minimized.

Copy link

PatrickQuintal commented Oct 13, 2019

I'm somewhat leaning towards 🅰️ for a slightly different reason.

I don't publish NPM packages, so I suppose my opinion doesn't matter too much, but I read files array "sequentially" and being processed in the following;

  1. We include lib, its a directory, its got an ignore file, lets do (all files) then subtract the .npmignore.
  2. Specifically remove a file.
  3. Specifically include a file, its a file. So lets ignore the .npmignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.