npm-packlist 1.1.6 → 1.1.10

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 +7 -6
  2. package/index.js +14 -5
  3. package/package.json +16 -4
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # npm-packlist
2
2
 
3
+ [![Build Status](https://travis-ci.com/npm/npm-packlist.svg?token=hHeDp9pQmz9kvsgRNVHy&branch=master)](https://travis-ci.com/npm/npm-packlist)
4
+
3
5
  Get a list of the files to add from a folder into an npm package
4
6
 
5
7
  These can be handed to [tar](http://npm.im/tar) like so to make an npm
@@ -46,12 +48,11 @@ This uses the following rules:
46
48
  1. .npmignore and .gitignore files (their effect is in the package
47
49
  already, there's no need to include them in the package)
48
50
  2. editor junk like `.*.swp`, `._*` and `.*.orig` files
49
- 3. A `/test/` or `/tests/` folder at the root
50
- 4. `.npmrc` files (these may contain private configs)
51
- 5. The `node_modules/.bin` folder
52
- 6. Waf and gyp cruft like `/build/config.gypi` and `.lock-wscript`
53
- 7. Darwin's `.DS_Store` files because wtf are those even
54
- 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
55
56
 
56
57
  You can explicitly re-include any of these with a `files` list in
57
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
 
@@ -66,15 +65,22 @@ const npmWalker = Class => class Walker extends Class {
66
65
  const rules = defaultRules.join('\n') + '\n'
67
66
  this.packageJsonCache = opt.packageJsonCache || new Map()
68
67
  super.onReadIgnoreFile(rootBuiltinRules, rules, _=>_)
69
- } else
68
+ } else {
69
+ this.bundled = []
70
+ this.bundledScopes = []
70
71
  this.packageJsonCache = this.parent.packageJsonCache
72
+ }
71
73
  }
72
74
 
73
75
  filterEntry (entry, partial) {
74
76
  // get the partial path from the root of the walk
75
77
  const p = this.path.substr(this.root.length + 1)
76
78
  const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/
77
- 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'
78
84
 
79
85
  return (
80
86
  // if we're in a bundled package, check with the parent.
@@ -84,14 +90,17 @@ const npmWalker = Class => class Walker extends Class {
84
90
  // if package is bundled, all files included
85
91
  // also include @scope dirs for bundled scoped deps
86
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.
87
96
  : pkg ? -1 !== this.bundled.indexOf(pkg) ||
88
97
  -1 !== this.bundledScopes.indexOf(pkg)
89
98
 
90
99
  // only walk top node_modules if we want to bundle something
91
- : entry === 'node_modules' && !this.parent ? !!this.bundled.length
100
+ : rootNM ? !!this.bundled.length
92
101
 
93
102
  // always include package.json at the root.
94
- : entry === 'package.json' && !this.parent ? true
103
+ : rootPJ ? true
95
104
 
96
105
  // otherwise, follow ignore-walk's logic
97
106
  : super.filterEntry(entry, partial)
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "npm-packlist",
3
- "version": "1.1.6",
3
+ "version": "1.1.10",
4
+ "description": "Get a list of the files to add from a folder into an npm package",
5
+ "directories": {
6
+ "test": "test"
7
+ },
4
8
  "main": "index.js",
5
9
  "dependencies": {
6
- "ignore-walk": "^3.0.0",
10
+ "ignore-walk": "^3.0.1",
7
11
  "npm-bundled": "^1.0.1"
8
12
  },
9
13
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
@@ -14,12 +18,20 @@
14
18
  "devDependencies": {
15
19
  "mkdirp": "^0.5.1",
16
20
  "rimraf": "^2.6.1",
17
- "tap": "^10.3.2"
21
+ "tap": "^10.7.2"
18
22
  },
19
23
  "scripts": {
20
24
  "test": "tap test/*.js --100 -J",
21
25
  "preversion": "npm test",
22
26
  "postversion": "npm publish",
23
27
  "postpublish": "git push origin --all; git push origin --tags"
24
- }
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/npm/npm-packlist.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/npm/npm-packlist/issues"
35
+ },
36
+ "homepage": "https://www.npmjs.com/package/npm-packlist"
25
37
  }