From 0061b858b2739d4deb7730362e0f0c790e16a98c Mon Sep 17 00:00:00 2001 From: Emily Xiong Date: Fri, 27 Sep 2024 12:09:04 -0400 Subject: [PATCH] fix(core): only stop daemon if enabled (#28146) ## Current Behavior ## Expected Behavior ## Related Issue(s) Fixes https://github.com/nrwl/nx/issues/27971 --- packages/nx/src/command-line/reset/reset.ts | 27 ++++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/nx/src/command-line/reset/reset.ts b/packages/nx/src/command-line/reset/reset.ts index 4be455c060..62af682f14 100644 --- a/packages/nx/src/command-line/reset/reset.ts +++ b/packages/nx/src/command-line/reset/reset.ts @@ -42,15 +42,15 @@ export async function resetHandler(args: ResetCommandOptions) { if (all || args.onlyDaemon) { try { await killDaemon(); - } catch { - errors.push('Failed to stop the Nx Daemon.'); + } catch (e) { + errors.push('Failed to stop the Nx Daemon.', e.toString()); } } if (all || args.onlyCache) { try { await cleanupCacheEntries(); - } catch { - errors.push('Failed to clean up the cache directory.'); + } catch (e) { + errors.push('Failed to clean up the cache directory.', e.toString()); } } if (all || args.onlyWorkspaceData) { @@ -61,12 +61,19 @@ export async function resetHandler(args: ResetCommandOptions) { } try { await cleanupWorkspaceData(); - } catch { - errors.push('Failed to clean up the workspace data directory.'); + } catch (e) { + errors.push( + 'Failed to clean up the workspace data directory.', + e.toString() + ); } } if (all || args.onlyCloud) { - await resetCloudClient(); + try { + await resetCloudClient(); + } catch (e) { + errors.push('Failed to reset the Nx Cloud client.', e.toString()); + } } if (errors.length > 0) { output.error({ @@ -81,8 +88,10 @@ export async function resetHandler(args: ResetCommandOptions) { } } -function killDaemon() { - return daemonClient.stop(); +async function killDaemon(): Promise { + if (daemonClient.enabled()) { + return daemonClient.stop(); + } } async function resetCloudClient() {