mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-12 10:11:42 -04:00
fix: reject null named catalogs in workspace manifest reader (#11231)
This commit is contained in:
committed by
Zoltan Kochan
parent
16b347620b
commit
f543b77006
6
.changeset/gentle-hats-doubt.md
Normal file
6
.changeset/gentle-hats-doubt.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/workspace.workspace-manifest-reader": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Reject `null` named catalogs in workspace manifests with `InvalidWorkspaceManifestError` instead of crashing with a raw `TypeError`.
|
||||
@@ -46,6 +46,10 @@ export function assertValidWorkspaceManifestCatalogs (manifest: { packages?: rea
|
||||
throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - array`)
|
||||
}
|
||||
|
||||
if (catalog === null) {
|
||||
throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - null`)
|
||||
}
|
||||
|
||||
if (typeof catalog !== 'object') {
|
||||
throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - ${typeof catalog}`)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
packages:
|
||||
- "packages/**"
|
||||
- "types"
|
||||
|
||||
catalogs:
|
||||
foo: null
|
||||
@@ -133,6 +133,15 @@ describe('readWorkspaceManifest() catalogs field', () => {
|
||||
).rejects.toThrow('Expected named catalog foo to be an object, but found - number')
|
||||
})
|
||||
|
||||
test('throws on null named catalog', async () => {
|
||||
await expect(
|
||||
readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-invalid-named-catalog-null'))
|
||||
).rejects.toMatchObject({
|
||||
code: 'ERR_PNPM_INVALID_WORKSPACE_CONFIGURATION',
|
||||
message: expect.stringContaining('Expected named catalog foo to be an object, but found - null'),
|
||||
})
|
||||
})
|
||||
|
||||
test('throws on invalid named catalog specifier', async () => {
|
||||
await expect(
|
||||
readWorkspaceManifest(path.join(import.meta.dirname, '__fixtures__/catalogs-invalid-named-catalog-specifier'))
|
||||
|
||||
Reference in New Issue
Block a user