npm-packlist
Advanced tools
Comparing version 8.0.1 to 8.0.2
@@ -45,16 +45,2 @@ 'use strict' | ||
const allLevels = [ | ||
// these are included by default but can be excluded by package.json files array | ||
'!/readme{,.*[^~$]}', | ||
'!/copying{,.*[^~$]}', | ||
'!/license{,.*[^~$]}', | ||
'!/licence{,.*[^~$]}', | ||
] | ||
const rootOnly = [ | ||
/^!.*readme/i, | ||
/^!.*copying/i, | ||
/^!.*licen[sc]e/i, | ||
] | ||
const normalizePath = (path) => path.split('\\').join('/') | ||
@@ -145,3 +131,2 @@ | ||
...strictDefaults, | ||
...allLevels, | ||
...this.requiredFiles.map((file) => `!${file}`), | ||
@@ -299,4 +284,7 @@ ]) | ||
...strictDefaults, | ||
...allLevels, | ||
'!/package.json', | ||
'!/readme{,.*[^~$]}', | ||
'!/copying{,.*[^~$]}', | ||
'!/license{,.*[^~$]}', | ||
'!/licence{,.*[^~$]}', | ||
'/.git', | ||
@@ -316,9 +304,7 @@ '/node_modules', | ||
file = file.slice(1) | ||
} else if (file.endsWith('/*')) { | ||
file = file.slice(0, -1) | ||
} | ||
if (file.endsWith('/*')) { | ||
file += '*' | ||
} | ||
const inverse = `!${file}` | ||
this.excludeNonRoot(file) | ||
try { | ||
@@ -372,16 +358,2 @@ // if an entry in the files array is a specific file, then we need to include it as a | ||
// excludes non root files by checking if elements from the files array in | ||
// package.json contain an ! and readme/license/licence/copying, and then | ||
// removing readme/license/licence/copying accordingly from strict defaults | ||
excludeNonRoot (file) { | ||
// Find the pattern | ||
const matchingPattern = rootOnly.find(regex => regex.test(file)) | ||
if (matchingPattern) { | ||
// Find which index matches the pattern and remove it from allLevels | ||
const indexToRemove = allLevels.findIndex(element => matchingPattern.test(element)) | ||
allLevels.splice(indexToRemove, 1) | ||
} | ||
} | ||
// custom method: after we've finished gathering the files for the root package, we call this | ||
@@ -388,0 +360,0 @@ // before emitting the 'done' event in order to gather all of the files for bundled deps |
{ | ||
"name": "npm-packlist", | ||
"version": "8.0.1", | ||
"version": "8.0.2", | ||
"description": "Get a list of the files to add from a folder into an npm package", | ||
@@ -5,0 +5,0 @@ "directories": { |
22206
400