npm-packlist 2.0.2 → 2.1.2
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/bin/index.js +0 -0
- package/index.js +40 -5
- package/package.json +7 -6
package/bin/index.js
CHANGED
|
File without changes
|
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(
|
|
@@ -123,6 +133,23 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
123
133
|
return super.onReaddir(entries)
|
|
124
134
|
}
|
|
125
135
|
|
|
136
|
+
// when the cache has been seeded with the root manifest,
|
|
137
|
+
// we must respect that (it may differ from the filesystem)
|
|
138
|
+
const ig = path.resolve(this.path, 'package.json')
|
|
139
|
+
|
|
140
|
+
if (this.packageJsonCache.has(ig)) {
|
|
141
|
+
const pkg = this.packageJsonCache.get(ig)
|
|
142
|
+
|
|
143
|
+
// fall back to filesystem when seeded manifest is invalid
|
|
144
|
+
if (!pkg || typeof pkg !== 'object') {
|
|
145
|
+
return this.readPackageJson(entries)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// feels wonky, but this ensures package bin is _always_
|
|
149
|
+
// normalized, as well as guarding against invalid JSON
|
|
150
|
+
return this.getPackageFiles(entries, JSON.stringify(pkg))
|
|
151
|
+
}
|
|
152
|
+
|
|
126
153
|
this.readPackageJson(entries)
|
|
127
154
|
}
|
|
128
155
|
|
|
@@ -164,12 +191,20 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
164
191
|
const ig = path.resolve(this.path, 'package.json')
|
|
165
192
|
this.packageJsonCache.set(ig, pkg)
|
|
166
193
|
|
|
167
|
-
// no files list
|
|
194
|
+
// no files list, just return the normal readdir() result
|
|
168
195
|
if (!Array.isArray(pkg.files))
|
|
169
196
|
return super.onReaddir(entries)
|
|
170
197
|
|
|
171
198
|
pkg.files.push(...this.mustHaveFilesFromPackage(pkg))
|
|
172
199
|
|
|
200
|
+
// If the package has a files list, then it's unlikely to include
|
|
201
|
+
// node_modules, because why would you do that? but since we use
|
|
202
|
+
// the files list as the effective readdir result, that means it
|
|
203
|
+
// looks like we don't have a node_modules folder at all unless we
|
|
204
|
+
// include it here.
|
|
205
|
+
if (pkg.bundleDependencies && entries.includes('node_modules'))
|
|
206
|
+
pkg.files.push('node_modules')
|
|
207
|
+
|
|
173
208
|
const patterns = Array.from(new Set(pkg.files)).reduce((set, pattern) => {
|
|
174
209
|
const excl = pattern.match(/^!+/)
|
|
175
210
|
if (excl)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-packlist",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
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,11 +18,9 @@
|
|
|
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",
|
|
@@ -42,5 +40,8 @@
|
|
|
42
40
|
"--include=bin/index.js"
|
|
43
41
|
]
|
|
44
42
|
},
|
|
45
|
-
"bin": "bin/index.js"
|
|
43
|
+
"bin": "bin/index.js",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=10"
|
|
46
|
+
}
|
|
46
47
|
}
|