npm-packlist 1.4.3 → 1.4.4

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.
Files changed (2) hide show
  1. package/index.js +20 -11
  2. package/package.json +5 -4
package/index.js CHANGED
@@ -92,8 +92,12 @@ const npmWalker = Class => class Walker extends Class {
92
92
  }
93
93
 
94
94
  onReaddir (entries) {
95
- if (!this.parent)
96
- entries = entries.filter(e => e !== '.git')
95
+ if (!this.parent) {
96
+ entries = entries.filter(e =>
97
+ e !== '.git' &&
98
+ !(e === 'node_modules' && this.bundled.length === 0)
99
+ )
100
+ }
97
101
  return super.onReaddir(entries)
98
102
  }
99
103
 
@@ -249,15 +253,20 @@ const walkSync = options => {
249
253
  return walker.result
250
254
  }
251
255
 
252
- // package.json first, node_modules last, files before folders, alphasort
253
- const sort = (a, b) =>
254
- a === 'package.json' ? -1
255
- : b === 'package.json' ? 1
256
- : /^node_modules/.test(a) && !/^node_modules/.test(b) ? 1
257
- : /^node_modules/.test(b) && !/^node_modules/.test(a) ? -1
258
- : path.dirname(a) === '.' && path.dirname(b) !== '.' ? -1
259
- : path.dirname(b) === '.' && path.dirname(a) !== '.' ? 1
260
- : a.localeCompare(b)
256
+ // optimize for compressibility
257
+ // extname, then basename, then locale alphabetically
258
+ // https://twitter.com/isntitvacant/status/1131094910923231232
259
+ const sort = (a, b) => {
260
+ const exta = path.extname(a).toLowerCase()
261
+ const extb = path.extname(b).toLowerCase()
262
+ const basea = path.basename(a).toLowerCase()
263
+ const baseb = path.basename(b).toLowerCase()
264
+
265
+ return exta.localeCompare(extb) ||
266
+ basea.localeCompare(baseb) ||
267
+ a.localeCompare(b)
268
+ }
269
+
261
270
 
262
271
  module.exports = walk
263
272
  walk.sync = walkSync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-packlist",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Get a list of the files to add from a folder into an npm package",
5
5
  "directories": {
6
6
  "test": "test"
@@ -18,13 +18,14 @@
18
18
  "devDependencies": {
19
19
  "mkdirp": "^0.5.1",
20
20
  "rimraf": "^2.6.1",
21
- "tap": "^11.1.5"
21
+ "tap": "^14.2.1"
22
22
  },
23
23
  "scripts": {
24
- "test": "tap test/*.js --100 -J",
24
+ "test": "tap",
25
+ "snap": "tap",
25
26
  "preversion": "npm test",
26
27
  "postversion": "npm publish",
27
- "postpublish": "git push origin --all --follow-tags"
28
+ "postpublish": "git push origin --follow-tags"
28
29
  },
29
30
  "repository": {
30
31
  "type": "git",