Skip to content

Commit

Permalink
fix(core): handle workspaces set to null (#4039)
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Jan 31, 2022
1 parent 29d46e8 commit 093e8bb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .yarn/versions/1e028524.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/core": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/doctor"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export class Manifest {
}
}

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

const workspaces = Array.isArray(data.workspaces)
Expand Down
4 changes: 4 additions & 0 deletions packages/yarnpkg-core/tests/Manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ describe(`Manifest`, () => {
expect(manifest.name!.name).toEqual(`foo`);
});

it(`should handle 'workspaces' set to null`, () => {
expect(() => Manifest.fromText(`{"workspaces":null}`)).not.toThrow();
});

describe(`exportTo`, () => {
it(`should add a scripts field if a script was newly added`, () => {
const manifest = Manifest.fromText(`{}`);
Expand Down

0 comments on commit 093e8bb

Please sign in to comment.