Skip to content

Commit 8fc4df1

Browse files
committed
fix: always ignore .npmrc files at every level
1 parent 8e1d900 commit 8fc4df1

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ class PackWalker extends IgnoreWalker {
298298
'!/package.json',
299299
'/.git',
300300
'/node_modules',
301+
'.npmrc',
301302
'/package-lock.json',
302303
'/yarn.lock',
303304
'/pnpm-lock.yaml',

test/ignore-file-included-by-globstar.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,45 @@ const Arborist = require('@npmcli/arborist')
44
const t = require('tap')
55
const packlist = require('../')
66

7+
t.test('exclude certain files always', async t => {
8+
const path = t.testdir({
9+
'.npmrc': 'secrets=true',
10+
'.git': {
11+
HEAD: 'empty',
12+
},
13+
node_modules: {
14+
foo: {
15+
'index.js': '',
16+
},
17+
},
18+
subdir: {
19+
'other.js': '',
20+
'.npmrc': 'sneaky=true',
21+
},
22+
'index.js': '',
23+
'glorp.txt': '',
24+
'package.json': JSON.stringify({
25+
name: '@npmcli/globstar-test',
26+
version: '1.0.0',
27+
files: ['*'],
28+
}),
29+
'package-lock.json': '{}',
30+
'yarn.lock': '{}',
31+
'pnpm-lock.yaml': '{}',
32+
})
33+
const arborist = new Arborist({ path })
34+
const tree = await arborist.loadActual()
35+
const files = await packlist(tree)
36+
t.same(files, [
37+
'index.js',
38+
'subdir/other.js',
39+
'package.json',
40+
'glorp.txt',
41+
])
42+
})
43+
744
t.test('include a globstar, then exclude one of them', async (t) => {
845
const path = t.testdir({
9-
'foo.js': '',
1046
'bar.js': '',
1147
bar: {
1248
'bar.js': '',

0 commit comments

Comments
 (0)