mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 07:38:12 -05:00
fix: respect include-workspace-root npmrc option (#4928)
close #4906 Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
6
.changeset/cyan-eels-own.md
Normal file
6
.changeset/cyan-eels-own.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/config": minor
|
||||
"pnpm": minor
|
||||
---
|
||||
|
||||
New setting added: `include-workspace-root`. When it is set to `true`, the `run`, `exec`, `add`, and `test` commands will include the root package, when executed recursively [#4906](https://github.com/pnpm/pnpm/issues/4906)
|
||||
@@ -28,6 +28,7 @@ export interface Config {
|
||||
dir: string
|
||||
bin: string
|
||||
ignoreScripts?: boolean
|
||||
includeWorkspaceRoot?: boolean
|
||||
save?: boolean
|
||||
saveProd?: boolean
|
||||
saveDev?: boolean
|
||||
|
||||
@@ -63,6 +63,7 @@ export const types = Object.assign({
|
||||
'ignore-pnpmfile': Boolean,
|
||||
'ignore-workspace': Boolean,
|
||||
'ignore-workspace-root-check': Boolean,
|
||||
'include-workspace-root': Boolean,
|
||||
'legacy-dir-filtering': Boolean,
|
||||
'link-workspace-packages': [Boolean, 'deep'],
|
||||
lockfile: Boolean,
|
||||
|
||||
@@ -47,6 +47,7 @@ export const GLOBAL_OPTIONS = pick([
|
||||
'ignore-workspace',
|
||||
'workspace-packages',
|
||||
'workspace-root',
|
||||
'include-workspace-root',
|
||||
], allTypes)
|
||||
|
||||
export type CommandResponse = string | { output: string, exitCode: number } | undefined
|
||||
|
||||
@@ -197,7 +197,7 @@ export default async function run (inputArgv: string[]) {
|
||||
const relativeWSDirPath = () => path.relative(process.cwd(), wsDir) || '.'
|
||||
if (config.workspaceRoot) {
|
||||
filters.push({ filter: `{${relativeWSDirPath()}}`, followProdDepsOnly: false })
|
||||
} else if (cmd === 'run' || cmd === 'exec' || cmd === 'add' || cmd === 'test') {
|
||||
} else if (!config.includeWorkspaceRoot && (cmd === 'run' || cmd === 'exec' || cmd === 'add' || cmd === 'test')) {
|
||||
filters.push({ filter: `!{${relativeWSDirPath()}}`, followProdDepsOnly: false })
|
||||
}
|
||||
|
||||
|
||||
@@ -1499,6 +1499,34 @@ test('pnpm run should include the workspace root when --workspace-root option is
|
||||
expect(await exists('project/test')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('pnpm run should include the workspace root when include-workspace-root is set to true', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
location: '.',
|
||||
package: {
|
||||
scripts: {
|
||||
test: "node -e \"require('fs').writeFileSync('test','','utf8')\"",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project',
|
||||
version: '1.0.0',
|
||||
scripts: {
|
||||
test: "node -e \"require('fs').writeFileSync('test','','utf8')\"",
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
await fs.writeFile('.npmrc', 'include-workspace-root', 'utf8')
|
||||
await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] })
|
||||
|
||||
await execPnpm(['-r', 'test'])
|
||||
|
||||
expect(await exists('test')).toBeTruthy()
|
||||
expect(await exists('project/test')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('legacy directory filtering', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user