Skip to content
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: 1 addition & 1 deletion lib/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ async function asyncSteps (pkg, { steps, root, changes }) {
}

// expand "directories.bin"
if (steps.includes('binDir') && data.directories?.bin && !data.bin) {
if (steps.includes('binDir') && data.directories?.bin && !data.bin && pkg.path) {
const binPath = secureAndUnixifyPath(data.directories.bin)
const bins = await lazyLoadGlob()('**', { cwd: path.resolve(pkg.path, binPath) })
data.bin = bins.reduce((acc, binFile) => {
Expand Down
14 changes: 14 additions & 0 deletions test/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,20 @@ for (const [name, testNormalize] of Object.entries(testMethods)) {
t.strictSame(content.bin, { echo: 'bin/echo' })
})

t.test('directories.bin without filesystem path', async t => {
const p = new Pkg()
p.fromContent({
name: 'registry-test',
version: '1.0.0',
directories: {
bin: './bin',
},
})
await p.normalize({ steps: Pkg.normalizeSteps })
t.notOk(p.content.bin, 'bin should not be expanded without filesystem path')
t.ok(p.content.directories.bin, 'directories.bin should be preserved')
})

t.test('dedupe optional deps out of regular deps', async t => {
t.test('choose optional deps in conflict, removing empty dependencies', async t => {
const { content } = await testNormalize(t, ({
Expand Down
Loading