Skip to content

Commit

Permalink
fix: ignore directories.bin if bin is present
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Jun 1, 2023
1 parent adb0c17 commit 3b603c4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/normalize.js
Expand Up @@ -158,7 +158,7 @@ const normalize = async (pkg, { strict, steps }) => {
}

// expand "directories.bin"
if (steps.includes('binDir') && data.directories?.bin) {
if (steps.includes('binDir') && data.directories?.bin && !data.bin) {
const binsDir = path.resolve(pkg.path, path.join('.', path.join('/', data.directories.bin)))
const bins = await glob('**', { cwd: binsDir })
data.bin = bins.reduce((acc, binFile) => {
Expand Down
19 changes: 19 additions & 0 deletions test/prepare.js
Expand Up @@ -95,6 +95,25 @@ t.test('bin', t => {
t.strictSame(content.bin, { echo: 'bin/echo' })
})

t.test('directories.bin with bin', async t => {
const { content } = await pkg.prepare(t.testdir({
'package.json': JSON.stringify({
name: 'bin-test',
directories: {
bin: './bin',
},
bin: {
echo: './bin/echo',
},
}),
bin: {
echo: '#!/bin/sh\n\necho "hello world"',
echo2: '#!/bin/sh\n\necho "hello world2"',
},
}))
t.strictSame(content.bin, { echo: 'bin/echo' })
})

t.end()
})

Expand Down

0 comments on commit 3b603c4

Please sign in to comment.