Skip to content

Commit

Permalink
fix: always ignore .npmrc files at every level
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Dec 6, 2023
1 parent 8e1d900 commit 8fc4df1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/index.js
Expand Up @@ -298,6 +298,7 @@ class PackWalker extends IgnoreWalker {
'!/package.json',
'/.git',
'/node_modules',
'.npmrc',
'/package-lock.json',
'/yarn.lock',
'/pnpm-lock.yaml',
Expand Down
38 changes: 37 additions & 1 deletion test/ignore-file-included-by-globstar.js
Expand Up @@ -4,9 +4,45 @@ const Arborist = require('@npmcli/arborist')
const t = require('tap')
const packlist = require('../')

t.test('exclude certain files always', async t => {
const path = t.testdir({
'.npmrc': 'secrets=true',
'.git': {
HEAD: 'empty',
},
node_modules: {
foo: {
'index.js': '',
},
},
subdir: {
'other.js': '',
'.npmrc': 'sneaky=true',
},
'index.js': '',
'glorp.txt': '',
'package.json': JSON.stringify({
name: '@npmcli/globstar-test',
version: '1.0.0',
files: ['*'],
}),
'package-lock.json': '{}',
'yarn.lock': '{}',
'pnpm-lock.yaml': '{}',
})
const arborist = new Arborist({ path })
const tree = await arborist.loadActual()
const files = await packlist(tree)
t.same(files, [
'index.js',
'subdir/other.js',
'package.json',
'glorp.txt',
])
})

t.test('include a globstar, then exclude one of them', async (t) => {
const path = t.testdir({
'foo.js': '',
'bar.js': '',
bar: {
'bar.js': '',
Expand Down

0 comments on commit 8fc4df1

Please sign in to comment.