fix(core): ensure safe removal of folders on daemon reset (#16766)

This commit is contained in:
Miroslav Jonaš 2023-05-04 17:12:18 +02:00 committed by GitHub
parent 17e6db5568
commit b7b04a7e43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { removeSync } from 'fs-extra'; import { rmSync } from 'fs-extra';
import { daemonClient } from '../daemon/client/client'; import { daemonClient } from '../daemon/client/client';
import { cacheDir, projectGraphCacheDirectory } from '../utils/cache-directory'; import { cacheDir, projectGraphCacheDirectory } from '../utils/cache-directory';
import { output } from '../utils/output'; import { output } from '../utils/output';
@ -10,9 +10,9 @@ export async function resetHandler() {
}); });
await daemonClient.stop(); await daemonClient.stop();
output.log({ title: 'Daemon Server - Stopped' }); output.log({ title: 'Daemon Server - Stopped' });
removeSync(cacheDir); rmSync(cacheDir, { recursive: true, force: true });
if (projectGraphCacheDirectory !== cacheDir) { if (projectGraphCacheDirectory !== cacheDir) {
removeSync(projectGraphCacheDirectory); rmSync(projectGraphCacheDirectory, { recursive: true, force: true });
} }
output.success({ output.success({
title: 'Successfully reset the Nx workspace.', title: 'Successfully reset the Nx workspace.',