fix: fixed extra-bin-paths not set if using ignore-script=true in a monorepo (#9522)

close #4858
This commit is contained in:
fxnm
2025-05-13 15:31:15 +02:00
committed by GitHub
parent e4af08ce18
commit 6cf010cfda
3 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/config": patch
"pnpm": patch
---
`pnpm run` should be able to run commands from the workspace root, if `ignoreScripts` is set tot `true` [#4858](https://github.com/pnpm/pnpm/issues/4858).

View File

@@ -388,7 +388,7 @@ export async function getConfig (opts: {
pnpmConfig.filterProd = (pnpmConfig.filterProd as string).split(' ')
}
if (!pnpmConfig.ignoreScripts && pnpmConfig.workspaceDir) {
if (pnpmConfig.workspaceDir) {
pnpmConfig.extraBinPaths = [path.join(pnpmConfig.workspaceDir, 'node_modules', '.bin')]
} else {
pnpmConfig.extraBinPaths = []

View File

@@ -331,6 +331,21 @@ test('extraBinPaths', async () => {
expect(config.extraBinPaths).toStrictEqual([path.resolve('node_modules/.bin')])
}
{
const { config } = await getConfig({
cliOptions: {
'ignore-scripts': true,
},
packageManager: {
name: 'pnpm',
version: '1.0.0',
},
workspaceDir: process.cwd(),
})
// extraBinPaths has the node_modules/.bin folder from the root of the workspace if scripts are ignored
expect(config.extraBinPaths).toStrictEqual([path.resolve('node_modules/.bin')])
}
{
const { config } = await getConfig({
cliOptions: {