diff --git a/lib/normalize.js b/lib/normalize.js index f65e6ad..0388220 100644 --- a/lib/normalize.js +++ b/lib/normalize.js @@ -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) => { diff --git a/test/normalize.js b/test/normalize.js index 59fa2b3..ba298a6 100644 --- a/test/normalize.js +++ b/test/normalize.js @@ -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, ({