mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-06 22:18:17 -05:00
fix(exec): commands of workspace project should be in PATH (#4583)
close #4481
This commit is contained in:
6
.changeset/strange-llamas-tie.md
Normal file
6
.changeset/strange-llamas-tie.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-script-runners": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
When `pnpm exec` is running a command in a workspace project, the commands that are in the dependencies of that workspace project should be in the PATH [#4481](https://github.com/pnpm/pnpm/issues/4481).
|
||||
@@ -137,7 +137,7 @@ export async function handler (
|
||||
PNPM_PACKAGE_NAME: opts.selectedProjectsGraph?.[prefix]?.package.manifest.name,
|
||||
},
|
||||
prependPaths: [
|
||||
path.join(opts.dir, 'node_modules/.bin'),
|
||||
path.join(prefix, 'node_modules/.bin'),
|
||||
...opts.extraBinPaths,
|
||||
],
|
||||
userAgent: opts.userAgent,
|
||||
|
||||
@@ -52,7 +52,7 @@ test('pnpm recursive exec', async () => {
|
||||
])
|
||||
|
||||
const { selectedProjectsGraph } = await readProjects(process.cwd(), [])
|
||||
await execa('pnpm', [
|
||||
await execa(pnpmBin, [
|
||||
'install',
|
||||
'-r',
|
||||
'--registry',
|
||||
@@ -74,6 +74,45 @@ test('pnpm recursive exec', async () => {
|
||||
expect(outputs2).toStrictEqual(['project-1', 'project-3'])
|
||||
})
|
||||
|
||||
test('pnpm recursive exec finds bin files of workspace projects', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
name: 'project-1',
|
||||
version: '1.0.0',
|
||||
|
||||
dependencies: {
|
||||
cowsay: '1.5.0',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project-2',
|
||||
version: '1.0.0',
|
||||
|
||||
dependencies: {
|
||||
cowsay: '1.5.0',
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const { selectedProjectsGraph } = await readProjects(process.cwd(), [])
|
||||
await execa(pnpmBin, [
|
||||
'install',
|
||||
'-r',
|
||||
'--registry',
|
||||
REGISTRY,
|
||||
'--store-dir',
|
||||
path.resolve(DEFAULT_OPTS.storeDir),
|
||||
])
|
||||
await exec.handler({
|
||||
...DEFAULT_OPTS,
|
||||
dir: process.cwd(),
|
||||
recursive: true,
|
||||
selectedProjectsGraph,
|
||||
}, ['cowsay', 'hi'])
|
||||
|
||||
// If there was no exception, the test passed
|
||||
})
|
||||
|
||||
test('exec inside a workspace package', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
@@ -115,7 +154,7 @@ test('exec inside a workspace package', async () => {
|
||||
},
|
||||
])
|
||||
|
||||
await execa('pnpm', [
|
||||
await execa(pnpmBin, [
|
||||
'install',
|
||||
'-r',
|
||||
'--registry',
|
||||
@@ -196,7 +235,7 @@ test('testing the bail config with "pnpm recursive exec"', async () => {
|
||||
])
|
||||
|
||||
const { selectedProjectsGraph } = await readProjects(process.cwd(), [])
|
||||
await execa('pnpm', [
|
||||
await execa(pnpmBin, [
|
||||
'install',
|
||||
'-r',
|
||||
'--registry',
|
||||
@@ -272,7 +311,7 @@ test('pnpm recursive exec --no-sort', async () => {
|
||||
])
|
||||
|
||||
const { selectedProjectsGraph } = await readProjects(process.cwd(), [])
|
||||
await execa('pnpm', [
|
||||
await execa(pnpmBin, [
|
||||
'install',
|
||||
'-r',
|
||||
'--registry',
|
||||
|
||||
Reference in New Issue
Block a user