From bb4291e2f34c9abe0e98467aa181f63872c3d06b Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 30 Aug 2022 10:39:11 +0000 Subject: [PATCH] fix(@angular-devkit/core): throw error when project has missing root property BREAKING CHANGE: Workspace projects with missing `root` is now an error. --- packages/angular_devkit/core/src/workspace/json/reader.ts | 6 +----- .../angular_devkit/core/src/workspace/json/reader_spec.ts | 7 ++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/angular_devkit/core/src/workspace/json/reader.ts b/packages/angular_devkit/core/src/workspace/json/reader.ts index 71035e28b08d..75038787154b 100644 --- a/packages/angular_devkit/core/src/workspace/json/reader.ts +++ b/packages/angular_devkit/core/src/workspace/json/reader.ts @@ -190,11 +190,7 @@ function parseProject( const projectNodeValue = getNodeValue(projectNode); if (!('root' in projectNodeValue)) { - // TODO(alan-agius4): change this to error in v15. - context.warn( - `Project "${projectName}" is missing a required property "root". This will become an error in the next major version.`, - projectNodeValue, - ); + throw new Error(`Project "${projectName}" is missing a required property "root".`); } for (const [name, value] of Object.entries(projectNodeValue)) { diff --git a/packages/angular_devkit/core/src/workspace/json/reader_spec.ts b/packages/angular_devkit/core/src/workspace/json/reader_spec.ts index 0d5728770a03..5b80cc50d92b 100644 --- a/packages/angular_devkit/core/src/workspace/json/reader_spec.ts +++ b/packages/angular_devkit/core/src/workspace/json/reader_spec.ts @@ -148,11 +148,8 @@ describe('readJsonWorkpace Parsing', () => { } `); - const consoleWarnSpy = spyOn(console, 'warn').and.callFake(() => undefined); - await expectAsync(readJsonWorkspace('', host)); - - expect(consoleWarnSpy).toHaveBeenCalledWith( - `Project "foo" is missing a required property "root". This will become an error in the next major version.`, + await expectAsync(readJsonWorkspace('', host)).toBeRejectedWithError( + /Project "foo" is missing a required property "root"/, ); }); });