Skip to content

Commit b9a8fd1

Browse files
filipesilvaclydin
authored andcommitted
fix(@angular-devkit/core): propagate node host delete errors
1 parent aa39019 commit b9a8fd1

File tree

1 file changed

+20
-13
lines changed
  • packages/angular_devkit/core/node

1 file changed

+20
-13
lines changed

packages/angular_devkit/core/node/host.ts

+20-13
Original file line numberDiff line numberDiff line change
@@ -264,25 +264,32 @@ export class NodeJsSyncHost implements virtualFs.Host<fs.Stats> {
264264
delete(path: Path): Observable<void> {
265265
return this.isDirectory(path).pipe(
266266
concatMap(isDir => {
267+
// TODO: remove this try+catch when issue https://github.com/ReactiveX/rxjs/issues/3740 is
268+
// fixed.
267269
if (isDir) {
268-
// Since this is synchronous, we can recurse and safely ignore the result.
269-
for (const name of fs.readdirSync(getSystemPath(path))) {
270-
this.delete(join(path, name)).subscribe();
271-
}
272-
try {
273-
fs.rmdirSync(getSystemPath(path));
274-
} catch (error) {
275-
return throwError(error);
276-
}
270+
const dirPaths = fs.readdirSync(getSystemPath(path));
271+
const rmDirComplete = new Observable((obs) => {
272+
try {
273+
fs.rmdirSync(getSystemPath(path));
274+
obs.complete();
275+
} catch (e) {
276+
obs.error(e);
277+
}
278+
});
279+
280+
return concat(
281+
...dirPaths.map(name => this.delete(join(path, name))),
282+
rmDirComplete,
283+
);
277284
} else {
278285
try {
279286
fs.unlinkSync(getSystemPath(path));
280-
} catch (error) {
281-
return throwError(error);
287+
} catch (err) {
288+
return throwError(err);
282289
}
283-
}
284290

285-
return EMPTY;
291+
return EMPTY;
292+
}
286293
}),
287294
);
288295
}

0 commit comments

Comments
 (0)