Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: treat glob the same as globstar #147

Merged
merged 3 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ class PackWalker extends IgnoreWalker {
file = file.slice(1)
} else if (file.startsWith('./')) {
file = file.slice(2)
} else if (file.endsWith('/*')) {
file = file.slice(0, -2)
}
const inverse = `!${file}`
try {
Expand Down
42 changes: 42 additions & 0 deletions test/package-json-directory-glob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict'

const Arborist = require('@npmcli/arborist')
const t = require('tap')
const packlist = require('..')

const createTestdir = (...files) => t.testdir({
'package.json': JSON.stringify({
files,
}),
folder: {
one: { file: 'one' },
two: { file: 'two' },
},
folder1: {
one: { file: 'one' },
two: { file: 'two' },
},
})

t.test('package json directory glob', async (t) => {
const pkgFiles = [
'folder',
'folder/',
'folder/*',
'folder/**',
]

for (const files of pkgFiles) {
await t.test(files, async t => {
const pkg = createTestdir(files)
const arborist = new Arborist({ path: pkg })
const tree = await arborist.loadActual()
const res = await packlist(tree)
t.same(res, [
'folder/one/file',
'folder/two/file',
'package.json',
])
})
}
})