Skip to content

Commit 299b2f2

Browse files
authored
fix(cdk/schematics): remove instanceof check since it was always false when checking if a directory exists (#24999)
1 parent b717203 commit 299b2f2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/cdk/schematics/ng-update/devkit-file-system.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ export class DevkitFileSystem extends FileSystem {
5353
try {
5454
this._tree.get(dirPath);
5555
} catch (e) {
56-
// Note: We do not use an `instanceof` check here. It could happen that the devkit version
57-
// used by the CLI is different than the one we end up loading. This can happen depending
58-
// on how Yarn/NPM hoists the NPM packages / whether there are multiple versions installed.
59-
if (e instanceof Error && e.constructor.name === 'PathIsDirectoryException') {
56+
// Note: We do not use an `instanceof` check here. It could happen that
57+
// the devkit version used by the CLI is different than the one we end up
58+
// loading. This can happen depending on how Yarn/NPM hoists the NPM
59+
// packages / whether there are multiple versions installed. Typescript
60+
// throws a compilation error if the type isn't specified and we can't
61+
// check the type, so we have to cast the error output to any.
62+
if ((e as any).constructor.name === 'PathIsDirectoryException') {
6063
return true;
6164
}
6265
}

0 commit comments

Comments
 (0)