Skip to content

Commit 093e8bb

Browse files
authored
fix(core): handle workspaces set to null (#4039)
1 parent 29d46e8 commit 093e8bb

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

.yarn/versions/1e028524.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/core": patch
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-exec"
11+
- "@yarnpkg/plugin-file"
12+
- "@yarnpkg/plugin-git"
13+
- "@yarnpkg/plugin-github"
14+
- "@yarnpkg/plugin-http"
15+
- "@yarnpkg/plugin-init"
16+
- "@yarnpkg/plugin-interactive-tools"
17+
- "@yarnpkg/plugin-link"
18+
- "@yarnpkg/plugin-nm"
19+
- "@yarnpkg/plugin-npm"
20+
- "@yarnpkg/plugin-npm-cli"
21+
- "@yarnpkg/plugin-pack"
22+
- "@yarnpkg/plugin-patch"
23+
- "@yarnpkg/plugin-pnp"
24+
- "@yarnpkg/plugin-pnpm"
25+
- "@yarnpkg/plugin-stage"
26+
- "@yarnpkg/plugin-typescript"
27+
- "@yarnpkg/plugin-version"
28+
- "@yarnpkg/plugin-workspace-tools"
29+
- "@yarnpkg/builder"
30+
- "@yarnpkg/doctor"
31+
- "@yarnpkg/nm"
32+
- "@yarnpkg/pnpify"
33+
- "@yarnpkg/sdks"

packages/yarnpkg-core/sources/Manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ export class Manifest {
410410
}
411411
}
412412

413-
if (typeof data.workspaces === `object` && data.workspaces.nohoist)
413+
if (typeof data.workspaces === `object` && data.workspaces !== null && data.workspaces.nohoist)
414414
errors.push(new Error(`'nohoist' is deprecated, please use 'installConfig.hoistingLimits' instead`));
415415

416416
const workspaces = Array.isArray(data.workspaces)

packages/yarnpkg-core/tests/Manifest.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ describe(`Manifest`, () => {
66
expect(manifest.name!.name).toEqual(`foo`);
77
});
88

9+
it(`should handle 'workspaces' set to null`, () => {
10+
expect(() => Manifest.fromText(`{"workspaces":null}`)).not.toThrow();
11+
});
12+
913
describe(`exportTo`, () => {
1014
it(`should add a scripts field if a script was newly added`, () => {
1115
const manifest = Manifest.fromText(`{}`);

0 commit comments

Comments
 (0)