From d3992e9453dcb7d89b759bcadb963754ac8df61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Thu, 3 Jun 2021 14:00:45 +0100 Subject: [PATCH] fix(core): override isDirectory in wrapped angular schematics host (#5869) --- packages/tao/src/commands/ngcli-adapter.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/tao/src/commands/ngcli-adapter.ts b/packages/tao/src/commands/ngcli-adapter.ts index c2278a9e5e..304d03605a 100644 --- a/packages/tao/src/commands/ngcli-adapter.ts +++ b/packages/tao/src/commands/ngcli-adapter.ts @@ -25,7 +25,7 @@ import { dirname, extname, resolve, join } from 'path'; import * as stripJsonComments from 'strip-json-comments'; import { FileBuffer } from '@angular-devkit/core/src/virtual-fs/host/interface'; import { Observable, of } from 'rxjs'; -import { map, switchMap } from 'rxjs/operators'; +import { catchError, map, switchMap } from 'rxjs/operators'; import { NX_ERROR, NX_PREFIX } from '../shared/logger'; export async function scheduleTarget( @@ -393,6 +393,17 @@ export class NxScopeHostUsedForWrappedSchematics extends NxScopedHost { } } + isDirectory(path: Path): Observable { + return super.isDirectory(path).pipe( + catchError(() => of(false)), + switchMap((isDirectory) => + isDirectory + ? of(true) + : of(this.host.exists(path) && !this.host.isFile(path)) + ) + ); + } + isFile(path: Path): Observable { if (isWorkspaceConfigPath(path)) { return findWorkspaceConfigFileChange(this.host)