From 1cae869ff04e7be35ee838a83a11a444a1db822d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Wed, 16 Feb 2022 17:54:44 +0000 Subject: [PATCH] fix(angular): handle different workspace version and format when falling back to the angular cli (#8993) --- packages/cli/lib/init-local.ts | 1 + packages/tao/src/compat/compat.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cli/lib/init-local.ts b/packages/cli/lib/init-local.ts index 0ea31527edf78..17250348f972b 100644 --- a/packages/cli/lib/init-local.ts +++ b/packages/cli/lib/init-local.ts @@ -103,6 +103,7 @@ export function initLocal(workspace: Workspace) { }) ); } else { + require('@nrwl/tao/src/compat/compat'); loadCli(workspace, '@angular/cli/lib/init.js'); } } diff --git a/packages/tao/src/compat/compat.ts b/packages/tao/src/compat/compat.ts index 27cf13f94998b..1df30bf61d08a 100644 --- a/packages/tao/src/compat/compat.ts +++ b/packages/tao/src/compat/compat.ts @@ -58,12 +58,12 @@ if (!patched) { `@angular-devkit/core/src/workspace/json/reader`, ]); const originalReadJsonWorkspace = readJsonUtils.readJsonWorkspace; - readJsonUtils.readJsonWorkspace = ( + readJsonUtils.readJsonWorkspace = async ( path, host: { readFile: (p) => Promise } ) => { try { - return originalReadJsonWorkspace(path, host); + return await originalReadJsonWorkspace(path, host); } catch { logger.debug( '[NX] Angular devkit readJsonWorkspace fell back to Nx workspaces logic'