Skip to content

Commit 3b603c4

Browse files
committed
fix: ignore directories.bin if bin is present
1 parent adb0c17 commit 3b603c4

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/normalize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const normalize = async (pkg, { strict, steps }) => {
158158
}
159159

160160
// expand "directories.bin"
161-
if (steps.includes('binDir') && data.directories?.bin) {
161+
if (steps.includes('binDir') && data.directories?.bin && !data.bin) {
162162
const binsDir = path.resolve(pkg.path, path.join('.', path.join('/', data.directories.bin)))
163163
const bins = await glob('**', { cwd: binsDir })
164164
data.bin = bins.reduce((acc, binFile) => {

test/prepare.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,25 @@ t.test('bin', t => {
9595
t.strictSame(content.bin, { echo: 'bin/echo' })
9696
})
9797

98+
t.test('directories.bin with bin', async t => {
99+
const { content } = await pkg.prepare(t.testdir({
100+
'package.json': JSON.stringify({
101+
name: 'bin-test',
102+
directories: {
103+
bin: './bin',
104+
},
105+
bin: {
106+
echo: './bin/echo',
107+
},
108+
}),
109+
bin: {
110+
echo: '#!/bin/sh\n\necho "hello world"',
111+
echo2: '#!/bin/sh\n\necho "hello world2"',
112+
},
113+
}))
114+
t.strictSame(content.bin, { echo: 'bin/echo' })
115+
})
116+
98117
t.end()
99118
})
100119

0 commit comments

Comments
 (0)