npm-packlist 1.1.9 → 1.2.0

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 +26 -10
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -20,10 +20,14 @@ const path = require('path')
20
20
  const defaultRules = [
21
21
  '.npmignore',
22
22
  '.gitignore',
23
- '**/.git/',
24
- '**/.svn/',
25
- '**/.hg/',
26
- '**/CVS/',
23
+ '**/.git',
24
+ '**/.svn',
25
+ '**/.hg',
26
+ '**/CVS',
27
+ '**/.git/**',
28
+ '**/.svn/**',
29
+ '**/.hg/**',
30
+ '**/CVS/**',
27
31
  '/.lock-wscript',
28
32
  '/.wafpickle-*',
29
33
  '/build/config.gypi',
@@ -33,7 +37,8 @@ const defaultRules = [
33
37
  '.DS_Store',
34
38
  '._*',
35
39
  '*.orig',
36
- 'package-lock.json'
40
+ 'package-lock.json',
41
+ 'archived-packages/**',
37
42
  ]
38
43
 
39
44
  // a decorator that applies our custom rules to an ignore walker
@@ -52,7 +57,11 @@ const npmWalker = Class => class Walker extends Class {
52
57
 
53
58
  opt.includeEmpty = false
54
59
  opt.path = opt.path || process.cwd()
55
- opt.follow = path.basename(opt.path) === 'node_modules'
60
+ const dirName = path.basename(opt.path)
61
+ const parentName = path.basename(path.dirname(opt.path))
62
+ opt.follow =
63
+ dirName === 'node_modules' ||
64
+ (parentName === 'node_modules' && /^@/.test(dirName))
56
65
  super(opt)
57
66
 
58
67
  // ignore a bunch of things by default at the root level.
@@ -76,7 +85,11 @@ const npmWalker = Class => class Walker extends Class {
76
85
  // get the partial path from the root of the walk
77
86
  const p = this.path.substr(this.root.length + 1)
78
87
  const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/
79
- const pkg = pkgre.test(entry) ? entry.replace(pkgre, '$1') : null
88
+ const isRoot = !this.parent
89
+ const pkg = isRoot && pkgre.test(entry) ?
90
+ entry.replace(pkgre, '$1') : null
91
+ const rootNM = isRoot && entry === 'node_modules'
92
+ const rootPJ = isRoot && entry === 'package.json'
80
93
 
81
94
  return (
82
95
  // if we're in a bundled package, check with the parent.
@@ -86,14 +99,17 @@ const npmWalker = Class => class Walker extends Class {
86
99
  // if package is bundled, all files included
87
100
  // also include @scope dirs for bundled scoped deps
88
101
  // they'll be ignored if no files end up in them.
102
+ // However, this only matters if we're in the root.
103
+ // node_modules folders elsewhere, like lib/node_modules,
104
+ // should be included normally unless ignored.
89
105
  : pkg ? -1 !== this.bundled.indexOf(pkg) ||
90
106
  -1 !== this.bundledScopes.indexOf(pkg)
91
107
 
92
108
  // only walk top node_modules if we want to bundle something
93
- : entry === 'node_modules' && !this.parent ? !!this.bundled.length
109
+ : rootNM ? !!this.bundled.length
94
110
 
95
111
  // always include package.json at the root.
96
- : entry === 'package.json' && !this.parent ? true
112
+ : rootPJ ? true
97
113
 
98
114
  // otherwise, follow ignore-walk's logic
99
115
  : super.filterEntry(entry, partial)
@@ -124,7 +140,7 @@ const npmWalker = Class => class Walker extends Class {
124
140
  const rules = [
125
141
  pkg.browser ? '!' + pkg.browser : '',
126
142
  pkg.main ? '!' + pkg.main : '',
127
- '!@(readme|license|licence|notice|changes|changelog|history){,.*}'
143
+ '!@(readme|copying|license|licence|notice|changes|changelog|history){,.*}'
128
144
  ].filter(f => f).join('\n') + '\n'
129
145
  super.onReadIgnoreFile(packageNecessaryRules, rules, _=>_)
130
146
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "npm-packlist",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
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"
7
7
  },
8
8
  "main": "index.js",
9
9
  "dependencies": {
10
- "ignore-walk": "^3.0.0",
10
+ "ignore-walk": "^3.0.1",
11
11
  "npm-bundled": "^1.0.1"
12
12
  },
13
13
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
@@ -18,7 +18,7 @@
18
18
  "devDependencies": {
19
19
  "mkdirp": "^0.5.1",
20
20
  "rimraf": "^2.6.1",
21
- "tap": "^10.3.2"
21
+ "tap": "^12.0.1"
22
22
  },
23
23
  "scripts": {
24
24
  "test": "tap test/*.js --100 -J",