npm-packlist 1.1.12 → 1.4.1
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 +34 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -34,11 +34,20 @@ const defaultRules = [
|
|
|
34
34
|
'npm-debug.log',
|
|
35
35
|
'**/.npmrc',
|
|
36
36
|
'.*.swp',
|
|
37
|
-
'
|
|
37
|
+
'**/.DS_Store/**',
|
|
38
38
|
'._*',
|
|
39
|
+
'**/._*/**',
|
|
39
40
|
'*.orig',
|
|
40
|
-
'package-lock.json',
|
|
41
|
+
'/package-lock.json',
|
|
42
|
+
'/yarn.lock',
|
|
41
43
|
'archived-packages/**',
|
|
44
|
+
'core',
|
|
45
|
+
'!core/',
|
|
46
|
+
'!**/core/',
|
|
47
|
+
'*.core',
|
|
48
|
+
'*.vgcore',
|
|
49
|
+
'vgcore.*',
|
|
50
|
+
'core.+([0-9])',
|
|
42
51
|
]
|
|
43
52
|
|
|
44
53
|
// a decorator that applies our custom rules to an ignore walker
|
|
@@ -57,7 +66,11 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
57
66
|
|
|
58
67
|
opt.includeEmpty = false
|
|
59
68
|
opt.path = opt.path || process.cwd()
|
|
60
|
-
|
|
69
|
+
const dirName = path.basename(opt.path)
|
|
70
|
+
const parentName = path.basename(path.dirname(opt.path))
|
|
71
|
+
opt.follow =
|
|
72
|
+
dirName === 'node_modules' ||
|
|
73
|
+
(parentName === 'node_modules' && /^@/.test(dirName))
|
|
61
74
|
super(opt)
|
|
62
75
|
|
|
63
76
|
// ignore a bunch of things by default at the root level.
|
|
@@ -132,13 +145,23 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
132
145
|
onPackageJson (ig, pkg, then) {
|
|
133
146
|
this.packageJsonCache.set(ig, pkg)
|
|
134
147
|
|
|
135
|
-
// if there's a browser or main, make sure we don't ignore it
|
|
148
|
+
// if there's a bin, browser or main, make sure we don't ignore it
|
|
149
|
+
// also, don't ignore the package.json itself!
|
|
136
150
|
const rules = [
|
|
137
151
|
pkg.browser ? '!' + pkg.browser : '',
|
|
138
152
|
pkg.main ? '!' + pkg.main : '',
|
|
139
|
-
'
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
'!package.json',
|
|
154
|
+
'!@(readme|copying|license|licence|notice|changes|changelog|history){,.*[^~$]}'
|
|
155
|
+
]
|
|
156
|
+
if (pkg.bin)
|
|
157
|
+
if (typeof pkg.bin === "object")
|
|
158
|
+
for (const key in pkg.bin)
|
|
159
|
+
rules.push('!' + pkg.bin[key])
|
|
160
|
+
else
|
|
161
|
+
rules.push('!' + pkg.bin)
|
|
162
|
+
|
|
163
|
+
const data = rules.filter(f => f).join('\n') + '\n'
|
|
164
|
+
super.onReadIgnoreFile(packageNecessaryRules, data, _=>_)
|
|
142
165
|
|
|
143
166
|
if (Array.isArray(pkg.files))
|
|
144
167
|
super.onReadIgnoreFile('package.json', '*\n' + pkg.files.map(
|
|
@@ -159,7 +182,8 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
159
182
|
onReadIgnoreFile (file, data, then) {
|
|
160
183
|
if (file === 'package.json')
|
|
161
184
|
try {
|
|
162
|
-
|
|
185
|
+
const ig = path.resolve(this.path, file)
|
|
186
|
+
this.onPackageJson(ig, JSON.parse(data), then)
|
|
163
187
|
} catch (er) {
|
|
164
188
|
// ignore package.json files that are not json
|
|
165
189
|
then()
|
|
@@ -189,12 +213,13 @@ class WalkerSync extends npmWalker(IgnoreWalkerSync) {
|
|
|
189
213
|
const walk = (options, callback) => {
|
|
190
214
|
options = options || {}
|
|
191
215
|
const p = new Promise((resolve, reject) => {
|
|
192
|
-
const bw = new BundleWalker(options)
|
|
216
|
+
const bw = new BundleWalker(options)
|
|
193
217
|
bw.on('done', bundled => {
|
|
194
218
|
options.bundled = bundled
|
|
195
219
|
options.packageJsonCache = bw.packageJsonCache
|
|
196
220
|
new Walker(options).on('done', resolve).on('error', reject).start()
|
|
197
221
|
})
|
|
222
|
+
bw.start()
|
|
198
223
|
})
|
|
199
224
|
return callback ? p.then(res => callback(null, res), callback) : p
|
|
200
225
|
}
|