npm-packlist 1.1.7 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +5 -6
  2. package/index.js +11 -4
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -48,12 +48,11 @@ This uses the following rules:
48
48
  1. .npmignore and .gitignore files (their effect is in the package
49
49
  already, there's no need to include them in the package)
50
50
  2. editor junk like `.*.swp`, `._*` and `.*.orig` files
51
- 3. A `/test/` or `/tests/` folder at the root
52
- 4. `.npmrc` files (these may contain private configs)
53
- 5. The `node_modules/.bin` folder
54
- 6. Waf and gyp cruft like `/build/config.gypi` and `.lock-wscript`
55
- 7. Darwin's `.DS_Store` files because wtf are those even
56
- 8. `npm-debug.log` files at the root of a project
51
+ 3. `.npmrc` files (these may contain private configs)
52
+ 4. The `node_modules/.bin` folder
53
+ 5. Waf and gyp cruft like `/build/config.gypi` and `.lock-wscript`
54
+ 6. Darwin's `.DS_Store` files because wtf are those even
55
+ 7. `npm-debug.log` files at the root of a project
57
56
 
58
57
  You can explicitly re-include any of these with a `files` list in
59
58
  `package.json` or a negated ignore file rule.
package/index.js CHANGED
@@ -33,7 +33,6 @@ const defaultRules = [
33
33
  '.DS_Store',
34
34
  '._*',
35
35
  '*.orig',
36
- '/test{,s}/',
37
36
  'package-lock.json'
38
37
  ]
39
38
 
@@ -68,6 +67,7 @@ const npmWalker = Class => class Walker extends Class {
68
67
  super.onReadIgnoreFile(rootBuiltinRules, rules, _=>_)
69
68
  } else {
70
69
  this.bundled = []
70
+ this.bundledScopes = []
71
71
  this.packageJsonCache = this.parent.packageJsonCache
72
72
  }
73
73
  }
@@ -76,7 +76,11 @@ const npmWalker = Class => class Walker extends Class {
76
76
  // get the partial path from the root of the walk
77
77
  const p = this.path.substr(this.root.length + 1)
78
78
  const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/
79
- const pkg = pkgre.test(entry) ? entry.replace(pkgre, '$1') : null
79
+ const isRoot = !this.parent
80
+ const pkg = isRoot && pkgre.test(entry) ?
81
+ entry.replace(pkgre, '$1') : null
82
+ const rootNM = isRoot && entry === 'node_modules'
83
+ const rootPJ = isRoot && entry === 'package.json'
80
84
 
81
85
  return (
82
86
  // if we're in a bundled package, check with the parent.
@@ -86,14 +90,17 @@ const npmWalker = Class => class Walker extends Class {
86
90
  // if package is bundled, all files included
87
91
  // also include @scope dirs for bundled scoped deps
88
92
  // they'll be ignored if no files end up in them.
93
+ // However, this only matters if we're in the root.
94
+ // node_modules folders elsewhere, like lib/node_modules,
95
+ // should be included normally unless ignored.
89
96
  : pkg ? -1 !== this.bundled.indexOf(pkg) ||
90
97
  -1 !== this.bundledScopes.indexOf(pkg)
91
98
 
92
99
  // only walk top node_modules if we want to bundle something
93
- : entry === 'node_modules' && !this.parent ? !!this.bundled.length
100
+ : rootNM ? !!this.bundled.length
94
101
 
95
102
  // always include package.json at the root.
96
- : entry === 'package.json' && !this.parent ? true
103
+ : rootPJ ? true
97
104
 
98
105
  // otherwise, follow ignore-walk's logic
99
106
  : super.filterEntry(entry, partial)
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "npm-packlist",
3
- "version": "1.1.7",
3
+ "version": "1.1.11",
4
4
  "description": "Get a list of the files to add from a folder into an npm package",
5
5
  "directories": {
6
6
  "test": "test"
7
7
  },
8
8
  "main": "index.js",
9
9
  "dependencies": {
10
- "ignore-walk": "^3.0.0",
10
+ "ignore-walk": "^3.0.1",
11
11
  "npm-bundled": "^1.0.1"
12
12
  },
13
13
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
@@ -18,7 +18,7 @@
18
18
  "devDependencies": {
19
19
  "mkdirp": "^0.5.1",
20
20
  "rimraf": "^2.6.1",
21
- "tap": "^10.3.2"
21
+ "tap": "^12.0.1"
22
22
  },
23
23
  "scripts": {
24
24
  "test": "tap test/*.js --100 -J",