feat: --ignore-workspace option

This commit is contained in:
Zoltan Kochan
2022-01-04 04:28:51 +02:00
parent 0da31c70c7
commit 8fe8f5e55e
5 changed files with 18 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/config": minor
"@pnpm/parse-cli-args": minor
"pnpm": minor
---
New CLI option: `--ignore-workspace`. When used, pnpm ignores any workspace configuration found in the current or parent directories.

View File

@@ -61,6 +61,7 @@ export const types = Object.assign({
hoist: Boolean,
'hoist-pattern': Array,
'ignore-pnpmfile': Boolean,
'ignore-workspace': Boolean,
'ignore-workspace-root-check': Boolean,
'link-workspace-packages': [Boolean, 'deep'],
lockfile: Boolean,

View File

@@ -120,7 +120,7 @@ export default async function parseCliArgs (
}
}
const dir = options['dir'] ?? process.cwd()
const workspaceDir = options['global'] // eslint-disable-line
const workspaceDir = options['global'] || options['ignore-workspace'] // eslint-disable-line
? undefined
: await findWorkspaceDir(dir)
if (options['workspace-root']) {

View File

@@ -66,6 +66,14 @@ test('when runnning a global command inside a workspace, the workspace should be
expect(workspaceDir).toBeFalsy()
})
test('when runnning with --ignore-workspace option inside a workspace, the workspace should be ignored', async () => {
const { workspaceDir } = await parseCliArgs({
...DEFAULT_OPTS,
universalOptionsTypes: { global: Boolean },
}, ['--ignore-workspace', 'add', 'foo'])
expect(workspaceDir).toBeFalsy()
})
test('command is used recursively', async () => {
const { cmd, options } = await parseCliArgs({
...DEFAULT_OPTS,

View File

@@ -42,6 +42,7 @@ export const GLOBAL_OPTIONS = pick([
'test-pattern',
'changed-files-ignore-pattern',
'use-stderr',
'ignore-workspace',
'workspace-packages',
'workspace-root',
], allTypes)