mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-08 23:18:26 -05:00
fix: allow scope registry cli option without --config. prefix (#9089)
close #9084. close #9085
This commit is contained in:
6
.changeset/lazy-pens-attend.md
Normal file
6
.changeset/lazy-pens-attend.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/parse-cli-args": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Allow scope registry CLI option without `--config.` prefix such as `--@scope:registry=https://scope.example.com/npm` [#9089](https://github.com/pnpm/pnpm/pull/9089).
|
||||
@@ -225,13 +225,17 @@ function getUnknownOptions (usedOptions: string[], knownOptions: Set<string>): M
|
||||
const unknownOptions = new Map<string, string[]>()
|
||||
const closestMatches = getClosestOptionMatches.bind(null, Array.from(knownOptions))
|
||||
for (const usedOption of usedOptions) {
|
||||
if (knownOptions.has(usedOption) || usedOption.startsWith('//')) continue
|
||||
if (knownOptions.has(usedOption) || usedOption.startsWith('//') || isScopeRegistryOption(usedOption)) continue
|
||||
|
||||
unknownOptions.set(usedOption, closestMatches(usedOption))
|
||||
}
|
||||
return unknownOptions
|
||||
}
|
||||
|
||||
function isScopeRegistryOption (optionName: string): boolean {
|
||||
return /^@[a-z0-9][\w.-]*:registry$/.test(optionName)
|
||||
}
|
||||
|
||||
function getClosestOptionMatches (knownOptions: string[], option: string): string[] {
|
||||
return didYouMean(option, knownOptions, {
|
||||
returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,
|
||||
|
||||
@@ -114,7 +114,7 @@ test('detect unknown options', async () => {
|
||||
return {}
|
||||
},
|
||||
universalOptionsTypes: { filter: [String, Array] },
|
||||
}, ['install', '--save-dev', '--registry=https://example.com', '--qar', '--filter=packages'])
|
||||
}, ['install', '--save-dev', '--registry=https://example.com', '--@scope:registry=https://scope.example.com/npm', '--qar', '--filter=packages'])
|
||||
expect(Array.from(unknownOptions.entries())).toStrictEqual([['save-dev', []], ['qar', ['bar']]])
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user