Skip to content

Commit 566ffc2

Browse files
authored
fix: log warning for .gitignore versus .npmignore logic (#265)
1 parent ead34b9 commit 566ffc2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const { Walker: IgnoreWalker } = require('ignore-walk')
44
const { lstatSync: lstat, readFileSync: readFile } = require('fs')
55
const { basename, dirname, extname, join, relative, resolve, sep } = require('path')
6+
const { log } = require('proc-log')
67

78
// symbols used to represent synthetic rule sets
89
const defaultRules = Symbol('npm-packlist.rules.default')
@@ -92,6 +93,7 @@ class PackWalker extends IgnoreWalker {
9293
}
9394

9495
super(options)
96+
9597
this.isPackage = options.isPackage
9698
this.seen = options.seen || new Set()
9799
this.tree = tree
@@ -168,6 +170,11 @@ class PackWalker extends IgnoreWalker {
168170
} else if (this.ignoreRules['.npmignore']) {
169171
// .npmignore means no .gitignore
170172
this.ignoreRules['.gitignore'] = null
173+
} else if (this.ignoreRules['.gitignore'] && !this.ignoreRules['.npmignore']) {
174+
log.warn(
175+
'gitignore-fallback',
176+
'No .npmignore file found, using .gitignore for file exclusion. Consider creating a .npmignore file to explicitly control published files.'
177+
)
171178
}
172179

173180
return super.filterEntries()

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
},
88
"main": "lib/index.js",
99
"dependencies": {
10-
"ignore-walk": "^8.0.0"
10+
"ignore-walk": "^8.0.0",
11+
"proc-log": "^5.0.0"
1112
},
1213
"author": "GitHub Inc.",
1314
"license": "ISC",

0 commit comments

Comments
 (0)