@@ -34,24 +34,33 @@ class Exec extends BaseCommand {
3434 for ( const [ name , path ] of this . workspaces ) {
3535 const locationMsg =
3636 `in workspace ${ this . npm . chalk . green ( name ) } at location:\n${ this . npm . chalk . dim ( path ) } `
37- await this . callExec ( args , { locationMsg, runPath : path } )
37+ await this . callExec ( args , { name , locationMsg, runPath : path } )
3838 }
3939 }
4040
41- async callExec ( args , { locationMsg, runPath } = { } ) {
42- // This is where libnpmexec will look for locally installed packages
41+ async callExec ( args , { name , locationMsg, runPath } = { } ) {
42+ // This is where libnpmexec will look for locally installed packages at the project level
4343 const localPrefix = this . npm . localPrefix
44+ // This is where libnpmexec will look for locally installed packages at the workspace level
45+ let localBin = this . npm . localBin
46+ let path = localPrefix
4447
4548 // This is where libnpmexec will actually run the scripts from
4649 if ( ! runPath ) {
4750 runPath = process . cwd ( )
51+ } else {
52+ // We have to consider if the workspace has its own separate versions
53+ // libnpmexec will walk up to localDir after looking here
54+ localBin = resolve ( this . npm . localDir , name , 'node_modules' , '.bin' )
55+ // We also need to look for `bin` entries in the workspace package.json
56+ // libnpmexec will NOT look in the project root for the bin entry
57+ path = runPath
4858 }
4959
5060 const call = this . npm . config . get ( 'call' )
5161 let globalPath
5262 const {
5363 flatOptions,
54- localBin,
5564 globalBin,
5665 globalDir,
5766 chalk,
@@ -79,14 +88,14 @@ class Exec extends BaseCommand {
7988 // copy args so they dont get mutated
8089 args : [ ...args ] ,
8190 call,
82- localBin,
83- locationMsg,
91+ chalk,
8492 globalBin,
8593 globalPath,
94+ localBin,
95+ locationMsg,
8696 output,
87- chalk,
8897 packages,
89- path : localPrefix ,
98+ path,
9099 runPath,
91100 scriptShell,
92101 yes,
0 commit comments