@@ -67,7 +67,7 @@ function normalizePackageBin (pkg, changes) {
6767 changes ?. push ( `"bin[${ binKey } ]" was renamed to "bin[${ base } ]"` )
6868 }
6969 if ( binTarget !== pkg . bin [ binKey ] ) {
70- changes ?. push ( `"bin[${ base } ]" script name was cleaned ` )
70+ changes ?. push ( `"bin[${ base } ]" script name ${ binTarget } was invalid and removed ` )
7171 }
7272 pkg . bin [ base ] = binTarget
7373 }
@@ -373,22 +373,19 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
373373 normalizePackageMan ( data , changes )
374374 }
375375
376- if ( steps . includes ( 'bin' ) || steps . includes ( 'binDir' ) || steps . includes ( 'binRefs' ) ) {
377- normalizePackageBin ( data , changes )
378- }
379-
380376 // expand "directories.bin"
381377 if ( steps . includes ( 'binDir' ) && data . directories ?. bin && ! data . bin ) {
382- const binsDir = path . resolve ( pkg . path , secureAndUnixifyPath ( data . directories . bin ) )
383- const bins = await lazyLoadGlob ( ) ( '**' , { cwd : binsDir } )
378+ const binPath = secureAndUnixifyPath ( data . directories . bin )
379+ const bins = await lazyLoadGlob ( ) ( '**' , { cwd : path . resolve ( pkg . path , binPath ) } )
384380 data . bin = bins . reduce ( ( acc , binFile ) => {
385381 if ( binFile && ! binFile . startsWith ( '.' ) ) {
386382 const binName = path . basename ( binFile )
387- acc [ binName ] = path . join ( data . directories . bin , binFile )
383+ // binPath is already cleaned and unixified, no need to path.join here.
384+ acc [ binName ] = `${ binPath } /${ secureAndUnixifyPath ( binFile ) } `
388385 }
389386 return acc
390387 } , { } )
391- // *sigh*
388+ } else if ( steps . includes ( 'bin' ) || steps . includes ( 'binDir' ) || steps . includes ( 'binRefs' ) ) {
392389 normalizePackageBin ( data , changes )
393390 }
394391
0 commit comments