npm-packlist 1.4.2 → 1.4.6

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 +35 -11
  2. package/package.json +9 -5
package/index.js CHANGED
@@ -34,6 +34,7 @@ const defaultRules = [
34
34
  'npm-debug.log',
35
35
  '**/.npmrc',
36
36
  '.*.swp',
37
+ '.DS_Store',
37
38
  '**/.DS_Store/**',
38
39
  '._*',
39
40
  '**/._*/**',
@@ -50,6 +51,9 @@ const defaultRules = [
50
51
  'core.+([0-9])',
51
52
  ]
52
53
 
54
+ // There may be others, but :?|<> are handled by node-tar
55
+ const nameIsBadForWindows = file => /\*/.test(file)
56
+
53
57
  // a decorator that applies our custom rules to an ignore walker
54
58
  const npmWalker = Class => class Walker extends Class {
55
59
  constructor (opt) {
@@ -91,8 +95,12 @@ const npmWalker = Class => class Walker extends Class {
91
95
  }
92
96
 
93
97
  onReaddir (entries) {
94
- if (!this.parent)
95
- entries = entries.filter(e => e !== '.git')
98
+ if (!this.parent) {
99
+ entries = entries.filter(e =>
100
+ e !== '.git' &&
101
+ !(e === 'node_modules' && this.bundled.length === 0)
102
+ )
103
+ }
96
104
  return super.onReaddir(entries)
97
105
  }
98
106
 
@@ -165,6 +173,7 @@ const npmWalker = Class => class Walker extends Class {
165
173
  pkg.browser ? '!' + pkg.browser : '',
166
174
  pkg.main ? '!' + pkg.main : '',
167
175
  '!package.json',
176
+ '!npm-shrinkwrap.json',
168
177
  '!@(readme|copying|license|licence|notice|changes|changelog|history){,.*[^~$]}'
169
178
  ]
170
179
  if (pkg.bin)
@@ -185,6 +194,16 @@ const npmWalker = Class => class Walker extends Class {
185
194
  then()
186
195
  }
187
196
 
197
+ // override parent stat function to completely skip any filenames
198
+ // that will break windows entirely.
199
+ // XXX(isaacs) Next major version should make this an error instead.
200
+ stat (entry, file, dir, then) {
201
+ if (nameIsBadForWindows(entry))
202
+ then()
203
+ else
204
+ super.stat(entry, file, dir, then)
205
+ }
206
+
188
207
  // override parent onstat function to nix all symlinks
189
208
  onstat (st, entry, file, dir, then) {
190
209
  if (st.isSymbolicLink())
@@ -248,15 +267,20 @@ const walkSync = options => {
248
267
  return walker.result
249
268
  }
250
269
 
251
- // package.json first, node_modules last, files before folders, alphasort
252
- const sort = (a, b) =>
253
- a === 'package.json' ? -1
254
- : b === 'package.json' ? 1
255
- : /^node_modules/.test(a) && !/^node_modules/.test(b) ? 1
256
- : /^node_modules/.test(b) && !/^node_modules/.test(a) ? -1
257
- : path.dirname(a) === '.' && path.dirname(b) !== '.' ? -1
258
- : path.dirname(b) === '.' && path.dirname(a) !== '.' ? 1
259
- : a.localeCompare(b)
270
+ // optimize for compressibility
271
+ // extname, then basename, then locale alphabetically
272
+ // https://twitter.com/isntitvacant/status/1131094910923231232
273
+ const sort = (a, b) => {
274
+ const exta = path.extname(a).toLowerCase()
275
+ const extb = path.extname(b).toLowerCase()
276
+ const basea = path.basename(a).toLowerCase()
277
+ const baseb = path.basename(b).toLowerCase()
278
+
279
+ return exta.localeCompare(extb) ||
280
+ basea.localeCompare(baseb) ||
281
+ a.localeCompare(b)
282
+ }
283
+
260
284
 
261
285
  module.exports = walk
262
286
  walk.sync = walkSync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-packlist",
3
- "version": "1.4.2",
3
+ "version": "1.4.6",
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.6.9"
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",
@@ -33,5 +34,8 @@
33
34
  "bugs": {
34
35
  "url": "https://github.com/npm/npm-packlist/issues"
35
36
  },
36
- "homepage": "https://www.npmjs.com/package/npm-packlist"
37
+ "homepage": "https://www.npmjs.com/package/npm-packlist",
38
+ "tap": {
39
+ "jobs": 1
40
+ }
37
41
  }