Skip to content

Commit

Permalink
fix(core): handle non-existing cli entry in nx.json in migration to r…
Browse files Browse the repository at this point in the history
…emove default collection (#10632)
  • Loading branch information
leosvelperez committed Jun 8, 2022
1 parent 31c753e commit d4274b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -41,4 +41,12 @@ describe('remove-default-collection', () => {
readWorkspaceConfiguration(tree).cli?.defaultCollection
).toBeUndefined();
});

it('should not error when "cli" is not defined', async () => {
const config = readWorkspaceConfiguration(tree);
delete config.cli;
updateWorkspaceConfiguration(tree, config);

await expect(removeDefaultCollection(tree)).resolves.not.toThrow();
});
});
Expand Up @@ -9,7 +9,10 @@ export default async function (tree: Tree) {
const workspaceConfiguration = readWorkspaceConfiguration(tree);

delete workspaceConfiguration.cli?.defaultCollection;
if (Object.keys(workspaceConfiguration.cli).length === 0) {
if (
workspaceConfiguration.cli &&
Object.keys(workspaceConfiguration.cli).length === 0
) {
delete workspaceConfiguration.cli;
}

Expand Down

0 comments on commit d4274b3

Please sign in to comment.