@@ -42,20 +42,6 @@ const strictDefaults = [
42
42
'/.git' ,
43
43
]
44
44
45
- const allLevels = [
46
- // these are included by default but can be excluded by package.json files array
47
- '!/readme{,.*[^~$]}' ,
48
- '!/copying{,.*[^~$]}' ,
49
- '!/license{,.*[^~$]}' ,
50
- '!/licence{,.*[^~$]}' ,
51
- ]
52
-
53
- const rootOnly = [
54
- / ^ ! .* r e a d m e / i,
55
- / ^ ! .* c o p y i n g / i,
56
- / ^ ! .* l i c e n [ s c ] e / i,
57
- ]
58
-
59
45
const normalizePath = ( path ) => path . split ( '\\' ) . join ( '/' )
60
46
61
47
const readOutOfTreeIgnoreFiles = ( root , rel , result = [ ] ) => {
@@ -141,7 +127,6 @@ class PackWalker extends IgnoreWalker {
141
127
// known required files for this directory
142
128
this . injectRules ( strictRules , [
143
129
...strictDefaults ,
144
- ...allLevels ,
145
130
...this . requiredFiles . map ( ( file ) => `!${ file } ` ) ,
146
131
] )
147
132
}
@@ -294,8 +279,11 @@ class PackWalker extends IgnoreWalker {
294
279
const ignores = [ ]
295
280
const strict = [
296
281
...strictDefaults ,
297
- ...allLevels ,
298
282
'!/package.json' ,
283
+ '!/readme{,.*[^~$]}' ,
284
+ '!/copying{,.*[^~$]}' ,
285
+ '!/license{,.*[^~$]}' ,
286
+ '!/licence{,.*[^~$]}' ,
299
287
'/.git' ,
300
288
'/node_modules' ,
301
289
'.npmrc' ,
@@ -310,13 +298,11 @@ class PackWalker extends IgnoreWalker {
310
298
// invert the rule because these are things we want to include
311
299
if ( file . startsWith ( './' ) ) {
312
300
file = file . slice ( 1 )
313
- } else if ( file . endsWith ( '/*' ) ) {
314
- file = file . slice ( 0 , - 1 )
301
+ }
302
+ if ( file . endsWith ( '/*' ) ) {
303
+ file += '*'
315
304
}
316
305
const inverse = `!${ file } `
317
-
318
- this . excludeNonRoot ( file )
319
-
320
306
try {
321
307
// if an entry in the files array is a specific file, then we need to include it as a
322
308
// strict requirement for this package. if it's a directory or a pattern, it's a default
@@ -365,20 +351,6 @@ class PackWalker extends IgnoreWalker {
365
351
this . injectRules ( strictRules , strict , callback )
366
352
}
367
353
368
- // excludes non root files by checking if elements from the files array in
369
- // package.json contain an ! and readme/license/licence/copying, and then
370
- // removing readme/license/licence/copying accordingly from strict defaults
371
- excludeNonRoot ( file ) {
372
- // Find the pattern
373
- const matchingPattern = rootOnly . find ( regex => regex . test ( file ) )
374
-
375
- if ( matchingPattern ) {
376
- // Find which index matches the pattern and remove it from allLevels
377
- const indexToRemove = allLevels . findIndex ( element => matchingPattern . test ( element ) )
378
- allLevels . splice ( indexToRemove , 1 )
379
- }
380
- }
381
-
382
354
// custom method: after we've finished gathering the files for the root package, we call this
383
355
// before emitting the 'done' event in order to gather all of the files for bundled deps
384
356
async gatherBundles ( ) {
0 commit comments