diff --git a/node_modules/npm-packlist/index.js b/node_modules/npm-packlist/index.js index 3bda08330afe2..cf87b18528b01 100644 --- a/node_modules/npm-packlist/index.js +++ b/node_modules/npm-packlist/index.js @@ -220,35 +220,47 @@ const npmWalker = Class => class Walker extends Class { let n = patterns.length const set = new Set() const negates = new Set() - const then = (pattern, negate, er, fileList) => { + const results = [] + const then = (pattern, negate, er, fileList, i) => { if (er) return this.emit('error', er) - if (negate) { - fileList.forEach(f => { - set.delete(f) - negates.add(f) - }) - } else { - fileList.forEach(f => { - set.add(f) - negates.delete(f) - }) - } - + results[i] = { negate, fileList } if (--n === 0) { - const list = Array.from(set) - // replace the files array with our computed explicit set - pkg.files = list.concat(Array.from(negates).map(f => '!' + f)) - const rdResult = Array.from(new Set( - list.map(f => f.replace(/^\/+/, '')) - )) - super.onReaddir(rdResult) + processResults(results) } } + const processResults = results => { + for (const {negate, fileList} of results) { + if (negate) { + fileList.forEach(f => { + f = f.replace(/\/+$/, '') + set.delete(f) + negates.add(f) + }) + } else { + fileList.forEach(f => { + f = f.replace(/\/+$/, '') + set.add(f) + negates.delete(f) + }) + } + } + + const list = Array.from(set) + // replace the files array with our computed explicit set + pkg.files = list.concat(Array.from(negates).map(f => '!' + f)) + const rdResult = Array.from(new Set( + list.map(f => f.replace(/^\/+/, '')) + )) + super.onReaddir(rdResult) + } - patterns.forEach(({pattern, negate}) => - this.globFiles(pattern, (er, res) => then(pattern, negate, er, res))) + // maintain the index so that we process them in-order only once all + // are completed, otherwise the parallelism messes things up, since a + // glob like **/*.js will always be slower than a subsequent !foo.js + patterns.forEach(({pattern, negate}, i) => + this.globFiles(pattern, (er, res) => then(pattern, negate, er, res, i))) } filterEntry (entry, partial) { diff --git a/node_modules/npm-packlist/package.json b/node_modules/npm-packlist/package.json index 0c23b633e4796..6f60521059a04 100644 --- a/node_modules/npm-packlist/package.json +++ b/node_modules/npm-packlist/package.json @@ -1,6 +1,6 @@ { "name": "npm-packlist", - "version": "2.1.2", + "version": "2.1.4", "description": "Get a list of the files to add from a folder into an npm package", "directories": { "test": "test" @@ -27,7 +27,7 @@ "snap": "tap", "preversion": "npm test", "postversion": "npm publish", - "postpublish": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags" }, "repository": { "type": "git", @@ -40,7 +40,9 @@ "--include=bin/index.js" ] }, - "bin": "bin/index.js", + "bin": { + "npm-packlist": "bin/index.js" + }, "engines": { "node": ">=10" } diff --git a/package-lock.json b/package-lock.json index 9a06e3202991b..2c09851d9811e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3876,9 +3876,10 @@ } }, "node_modules/npm-packlist": { - "version": "2.1.2", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-2.1.4.tgz", + "integrity": "sha512-Qzg2pvXC9U4I4fLnUrBmcIT4x0woLtUgxUi9eC+Zrcv1Xx5eamytGAfbDWQ67j7xOcQ2VW1I3su9smVTIdu7Hw==", "inBundle": true, - "license": "ISC", "dependencies": { "glob": "^7.1.6", "ignore-walk": "^3.0.3", @@ -10677,7 +10678,9 @@ } }, "npm-packlist": { - "version": "2.1.2", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-2.1.4.tgz", + "integrity": "sha512-Qzg2pvXC9U4I4fLnUrBmcIT4x0woLtUgxUi9eC+Zrcv1Xx5eamytGAfbDWQ67j7xOcQ2VW1I3su9smVTIdu7Hw==", "requires": { "glob": "^7.1.6", "ignore-walk": "^3.0.3",