@@ -42,20 +42,6 @@ const strictDefaults = [
4242 '/.git' ,
4343]
4444
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-
5945const normalizePath = ( path ) => path . split ( '\\' ) . join ( '/' )
6046
6147const readOutOfTreeIgnoreFiles = ( root , rel , result = [ ] ) => {
@@ -141,7 +127,6 @@ class PackWalker extends IgnoreWalker {
141127 // known required files for this directory
142128 this . injectRules ( strictRules , [
143129 ...strictDefaults ,
144- ...allLevels ,
145130 ...this . requiredFiles . map ( ( file ) => `!${ file } ` ) ,
146131 ] )
147132 }
@@ -294,8 +279,11 @@ class PackWalker extends IgnoreWalker {
294279 const ignores = [ ]
295280 const strict = [
296281 ...strictDefaults ,
297- ...allLevels ,
298282 '!/package.json' ,
283+ '!/readme{,.*[^~$]}' ,
284+ '!/copying{,.*[^~$]}' ,
285+ '!/license{,.*[^~$]}' ,
286+ '!/licence{,.*[^~$]}' ,
299287 '/.git' ,
300288 '/node_modules' ,
301289 '.npmrc' ,
@@ -310,13 +298,11 @@ class PackWalker extends IgnoreWalker {
310298 // invert the rule because these are things we want to include
311299 if ( file . startsWith ( './' ) ) {
312300 file = file . slice ( 1 )
313- } else if ( file . endsWith ( '/*' ) ) {
314- file = file . slice ( 0 , - 1 )
301+ }
302+ if ( file . endsWith ( '/*' ) ) {
303+ file += '*'
315304 }
316305 const inverse = `!${ file } `
317-
318- this . excludeNonRoot ( file )
319-
320306 try {
321307 // if an entry in the files array is a specific file, then we need to include it as a
322308 // 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 {
365351 this . injectRules ( strictRules , strict , callback )
366352 }
367353
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-
382354 // custom method: after we've finished gathering the files for the root package, we call this
383355 // before emitting the 'done' event in order to gather all of the files for bundled deps
384356 async gatherBundles ( ) {
0 commit comments