npm-packlist 2.1.0 → 2.1.4
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.
- package/index.js +48 -26
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -83,13 +83,23 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
83
83
|
opt.path = opt.path || process.cwd()
|
|
84
84
|
const dirName = path.basename(opt.path)
|
|
85
85
|
const parentName = path.basename(path.dirname(opt.path))
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
|
|
87
|
+
// only follow links in the root node_modules folder, because if those
|
|
88
|
+
// folders are included, it's because they're bundled, and bundles
|
|
89
|
+
// should include the contents, not the symlinks themselves.
|
|
90
|
+
// This regexp tests to see that we're either a node_modules folder,
|
|
91
|
+
// or a @scope within a node_modules folder, in the root's node_modules
|
|
92
|
+
// hierarchy (ie, not in test/foo/node_modules/ or something).
|
|
93
|
+
const followRe = /^(?:\/node_modules\/(?:@[^\/]+\/[^\/]+|[^\/]+)\/)*\/node_modules(?:\/@[^\/]+)?$/
|
|
94
|
+
const rootPath = opt.parent ? opt.parent.root : opt.path
|
|
95
|
+
const followTestPath = opt.path.replace(/\\/g, '/').substr(rootPath.length)
|
|
96
|
+
opt.follow = followRe.test(followTestPath)
|
|
97
|
+
|
|
89
98
|
super(opt)
|
|
90
99
|
|
|
91
100
|
// ignore a bunch of things by default at the root level.
|
|
92
|
-
// also ignore anything in
|
|
101
|
+
// also ignore anything in the main project node_modules hierarchy,
|
|
102
|
+
// except bundled dependencies
|
|
93
103
|
if (!this.parent) {
|
|
94
104
|
this.bundled = opt.bundled || []
|
|
95
105
|
this.bundledScopes = Array.from(new Set(
|
|
@@ -210,35 +220,47 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
210
220
|
let n = patterns.length
|
|
211
221
|
const set = new Set()
|
|
212
222
|
const negates = new Set()
|
|
213
|
-
const
|
|
223
|
+
const results = []
|
|
224
|
+
const then = (pattern, negate, er, fileList, i) => {
|
|
214
225
|
if (er)
|
|
215
226
|
return this.emit('error', er)
|
|
216
227
|
|
|
217
|
-
|
|
218
|
-
fileList.forEach(f => {
|
|
219
|
-
set.delete(f)
|
|
220
|
-
negates.add(f)
|
|
221
|
-
})
|
|
222
|
-
} else {
|
|
223
|
-
fileList.forEach(f => {
|
|
224
|
-
set.add(f)
|
|
225
|
-
negates.delete(f)
|
|
226
|
-
})
|
|
227
|
-
}
|
|
228
|
-
|
|
228
|
+
results[i] = { negate, fileList }
|
|
229
229
|
if (--n === 0) {
|
|
230
|
-
|
|
231
|
-
// replace the files array with our computed explicit set
|
|
232
|
-
pkg.files = list.concat(Array.from(negates).map(f => '!' + f))
|
|
233
|
-
const rdResult = Array.from(new Set(
|
|
234
|
-
list.map(f => f.replace(/^\/+/, ''))
|
|
235
|
-
))
|
|
236
|
-
super.onReaddir(rdResult)
|
|
230
|
+
processResults(results)
|
|
237
231
|
}
|
|
238
232
|
}
|
|
233
|
+
const processResults = results => {
|
|
234
|
+
for (const {negate, fileList} of results) {
|
|
235
|
+
if (negate) {
|
|
236
|
+
fileList.forEach(f => {
|
|
237
|
+
f = f.replace(/\/+$/, '')
|
|
238
|
+
set.delete(f)
|
|
239
|
+
negates.add(f)
|
|
240
|
+
})
|
|
241
|
+
} else {
|
|
242
|
+
fileList.forEach(f => {
|
|
243
|
+
f = f.replace(/\/+$/, '')
|
|
244
|
+
set.add(f)
|
|
245
|
+
negates.delete(f)
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const list = Array.from(set)
|
|
251
|
+
// replace the files array with our computed explicit set
|
|
252
|
+
pkg.files = list.concat(Array.from(negates).map(f => '!' + f))
|
|
253
|
+
const rdResult = Array.from(new Set(
|
|
254
|
+
list.map(f => f.replace(/^\/+/, ''))
|
|
255
|
+
))
|
|
256
|
+
super.onReaddir(rdResult)
|
|
257
|
+
}
|
|
239
258
|
|
|
240
|
-
|
|
241
|
-
|
|
259
|
+
// maintain the index so that we process them in-order only once all
|
|
260
|
+
// are completed, otherwise the parallelism messes things up, since a
|
|
261
|
+
// glob like **/*.js will always be slower than a subsequent !foo.js
|
|
262
|
+
patterns.forEach(({pattern, negate}, i) =>
|
|
263
|
+
this.globFiles(pattern, (er, res) => then(pattern, negate, er, res, i)))
|
|
242
264
|
}
|
|
243
265
|
|
|
244
266
|
filterEntry (entry, partial) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-packlist",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
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"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"glob": "^7.1.6",
|
|
11
11
|
"ignore-walk": "^3.0.3",
|
|
12
|
-
"npm-bundled": "^1.
|
|
12
|
+
"npm-bundled": "^1.1.1",
|
|
13
13
|
"npm-normalize-package-bin": "^1.0.1"
|
|
14
14
|
},
|
|
15
15
|
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
@@ -18,18 +18,16 @@
|
|
|
18
18
|
"index.js"
|
|
19
19
|
],
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"mkdirp": "^0.5.1",
|
|
22
21
|
"mutate-fs": "^2.1.1",
|
|
23
22
|
"require-inject": "^1.4.4",
|
|
24
|
-
"
|
|
25
|
-
"tap": "^14.7.0"
|
|
23
|
+
"tap": "^14.10.7"
|
|
26
24
|
},
|
|
27
25
|
"scripts": {
|
|
28
26
|
"test": "tap",
|
|
29
27
|
"snap": "tap",
|
|
30
28
|
"preversion": "npm test",
|
|
31
29
|
"postversion": "npm publish",
|
|
32
|
-
"
|
|
30
|
+
"prepublishOnly": "git push origin --follow-tags"
|
|
33
31
|
},
|
|
34
32
|
"repository": {
|
|
35
33
|
"type": "git",
|
|
@@ -42,7 +40,9 @@
|
|
|
42
40
|
"--include=bin/index.js"
|
|
43
41
|
]
|
|
44
42
|
},
|
|
45
|
-
"bin":
|
|
43
|
+
"bin": {
|
|
44
|
+
"npm-packlist": "bin/index.js"
|
|
45
|
+
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=10"
|
|
48
48
|
}
|