Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): handle non-existing cli entry in nx.json in migration to remove default collection #10632

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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();
});
});
Original file line number Diff line number Diff line change
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