npm-packlist 1.1.2 → 1.1.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.
- package/index.js +44 -9
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -20,8 +20,6 @@ const path = require('path')
|
|
|
20
20
|
const defaultRules = [
|
|
21
21
|
'.npmignore',
|
|
22
22
|
'.gitignore',
|
|
23
|
-
'/node_modules/**',
|
|
24
|
-
'/node_modules/.bin/**',
|
|
25
23
|
'**/.git/',
|
|
26
24
|
'**/.svn/',
|
|
27
25
|
'**/.hg/',
|
|
@@ -34,7 +32,7 @@ const defaultRules = [
|
|
|
34
32
|
'.*.swp',
|
|
35
33
|
'.DS_Store',
|
|
36
34
|
'._*',
|
|
37
|
-
'
|
|
35
|
+
'*.orig',
|
|
38
36
|
'/test{,s}/',
|
|
39
37
|
'package-lock.json'
|
|
40
38
|
]
|
|
@@ -62,15 +60,44 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
62
60
|
// also ignore anything in node_modules, except bundled dependencies
|
|
63
61
|
if (!this.parent) {
|
|
64
62
|
this.bundled = opt.bundled || []
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
this.bundledScopes = Array.from(new Set(
|
|
64
|
+
this.bundled.filter(f => /^@/.test(f))
|
|
65
|
+
.map(f => f.split('/')[0])))
|
|
66
|
+
const rules = defaultRules.join('\n') + '\n'
|
|
68
67
|
this.packageJsonCache = opt.packageJsonCache || new Map()
|
|
69
68
|
super.onReadIgnoreFile(rootBuiltinRules, rules, _=>_)
|
|
70
69
|
} else
|
|
71
70
|
this.packageJsonCache = this.parent.packageJsonCache
|
|
72
71
|
}
|
|
73
72
|
|
|
73
|
+
filterEntry (entry, partial) {
|
|
74
|
+
// get the partial path from the root of the walk
|
|
75
|
+
const p = this.path.substr(this.root.length + 1)
|
|
76
|
+
const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/
|
|
77
|
+
const pkg = pkgre.test(entry) ? entry.replace(pkgre, '$1') : null
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
// if we're in a bundled package, check with the parent.
|
|
81
|
+
/^node_modules($|\/)/i.test(p) ? this.parent.filterEntry(
|
|
82
|
+
this.basename + '/' + entry, partial)
|
|
83
|
+
|
|
84
|
+
// if package is bundled, all files included
|
|
85
|
+
// also include @scope dirs for bundled scoped deps
|
|
86
|
+
// they'll be ignored if no files end up in them.
|
|
87
|
+
: pkg ? -1 !== this.bundled.indexOf(pkg) ||
|
|
88
|
+
-1 !== this.bundledScopes.indexOf(pkg)
|
|
89
|
+
|
|
90
|
+
// only walk top node_modules if we want to bundle something
|
|
91
|
+
: entry === 'node_modules' && !this.parent ? !!this.bundled.length
|
|
92
|
+
|
|
93
|
+
// always include package.json at the root.
|
|
94
|
+
: entry === 'package.json' && !this.parent ? true
|
|
95
|
+
|
|
96
|
+
// otherwise, follow ignore-walk's logic
|
|
97
|
+
: super.filterEntry(entry, partial)
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
74
101
|
filterEntries () {
|
|
75
102
|
if (this.ignoreRules['package.json'])
|
|
76
103
|
this.ignoreRules['.gitignore'] = this.ignoreRules['.npmignore'] = null
|
|
@@ -95,12 +122,11 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
95
122
|
const rules = [
|
|
96
123
|
pkg.browser ? '!' + pkg.browser : '',
|
|
97
124
|
pkg.main ? '!' + pkg.main : '',
|
|
98
|
-
'!package.json',
|
|
99
125
|
'!@(readme|license|licence|notice|changes|changelog|history){,.*}'
|
|
100
126
|
].filter(f => f).join('\n') + '\n'
|
|
101
127
|
super.onReadIgnoreFile(packageNecessaryRules, rules, _=>_)
|
|
102
128
|
|
|
103
|
-
if (Array.isArray(pkg.files)
|
|
129
|
+
if (Array.isArray(pkg.files))
|
|
104
130
|
super.onReadIgnoreFile('package.json', '*\n' + pkg.files.map(
|
|
105
131
|
f => '!' + f + '\n!' + f.replace(/\/+$/, '') + '/**'
|
|
106
132
|
).join('\n') + '\n', then)
|
|
@@ -108,6 +134,14 @@ const npmWalker = Class => class Walker extends Class {
|
|
|
108
134
|
then()
|
|
109
135
|
}
|
|
110
136
|
|
|
137
|
+
// override parent onstat function to nix all symlinks
|
|
138
|
+
onstat (st, entry, file, dir, then) {
|
|
139
|
+
if (st.isSymbolicLink())
|
|
140
|
+
then()
|
|
141
|
+
else
|
|
142
|
+
super.onstat(st, entry, file, dir, then)
|
|
143
|
+
}
|
|
144
|
+
|
|
111
145
|
onReadIgnoreFile (file, data, then) {
|
|
112
146
|
if (file === 'package.json')
|
|
113
147
|
try {
|
|
@@ -132,8 +166,9 @@ class Walker extends npmWalker(IgnoreWalker) {
|
|
|
132
166
|
}
|
|
133
167
|
|
|
134
168
|
class WalkerSync extends npmWalker(IgnoreWalkerSync) {
|
|
135
|
-
walker (entry) {
|
|
169
|
+
walker (entry, then) {
|
|
136
170
|
new WalkerSync(this.walkerOpt(entry)).start()
|
|
171
|
+
then()
|
|
137
172
|
}
|
|
138
173
|
}
|
|
139
174
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-packlist",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"ignore-walk": "^
|
|
6
|
+
"ignore-walk": "^3.0.0",
|
|
7
7
|
"npm-bundled": "^1.0.1"
|
|
8
8
|
},
|
|
9
9
|
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|