Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: filter-prod flag including all workspace pkgs (#5437)
Co-authored-by: maxwellium <896080+maxwellium@users.noreply.github.com>
- Loading branch information
1 parent
5beb4e2
commit 5179dfe
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"pnpm": patch | ||
--- | ||
|
||
fix: Stop --filter-prod option to run command on all the projects when used on workspace. --filter-prod option now only filter from `dependencies` and omit `devDependencies` instead of including all the packages when used on workspace. So what was happening is that if you use `--filter-prod` on workspace root like this: | ||
```bash | ||
pnpm --filter-prod ...build-modules exec node -e 'console.log(require(`./package.json`).name)' | ||
``` | ||
it was printing all the package of workspace, where it should only print the package name of itself and packages where it has been added as `dependency` (not as `devDependencies`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import path from 'path' | ||
import writeYamlFile from 'write-yaml-file' | ||
import { execPnpm } from './utils' | ||
import { | ||
preparePackages, | ||
} from '@pnpm/prepare' | ||
|
||
test.each([ | ||
{ message: '--filter should include devDependencies', filter: '--filter', expected: ['project-1', 'project-3', 'project-4'] }, | ||
{ message: '--filter-prod should not include devDependencies', filter: '--filter-prod', expected: ['project-1', 'project-3'] }, | ||
])('$message', async ({ filter, expected }) => { | ||
preparePackages([ | ||
{ | ||
name: 'project-1', | ||
version: '1.0.0', | ||
dependencies: { 'project-2': '1.0.0', 'project-3': '1.0.0' }, | ||
devDependencies: { 'json-append': '1' }, | ||
scripts: { | ||
test: 'node -e "process.stdout.write(\'project-1\')" | json-append ../output.json', | ||
}, | ||
}, | ||
{ | ||
name: 'project-2', | ||
version: '1.0.0', | ||
dependencies: {}, | ||
devDependencies: { 'json-append': '1' }, | ||
scripts: { | ||
test: 'node -e "process.stdout.write(\'project-2\')" | json-append ../output.json', | ||
}, | ||
}, | ||
{ | ||
name: 'project-3', | ||
version: '1.0.0', | ||
dependencies: { 'project-2': '1.0.0' }, | ||
devDependencies: { 'json-append': '1' }, | ||
scripts: { | ||
test: 'node -e "process.stdout.write(\'project-3\')" | json-append ../output.json', | ||
}, | ||
}, | ||
{ | ||
name: 'project-4', | ||
version: '1.0.0', | ||
dependencies: {}, | ||
devDependencies: { 'json-append': '1', 'project-3': '1.0.0' }, | ||
scripts: { | ||
test: 'node -e "process.stdout.write(\'project-4\')" | json-append ../output.json', | ||
}, | ||
}, | ||
]) | ||
|
||
await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] }) | ||
await execPnpm(['install']) | ||
|
||
await execPnpm(['recursive', 'test', filter, '...project-3']) | ||
const { default: output } = await import(path.resolve('output.json')) | ||
expect(output.sort()).toStrictEqual(expected) | ||
}) |