Skip to content

Commit

Permalink
fix(core): only stop daemon if enabled (#28146)
Browse files Browse the repository at this point in the history
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #27971

(cherry picked from commit 0061b85)
  • Loading branch information
xiongemi authored and FrozenPandaz committed Sep 27, 2024
1 parent fb98769 commit e0b376a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/nx/src/command-line/reset/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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({
Expand All @@ -81,8 +88,10 @@ export async function resetHandler(args: ResetCommandOptions) {
}
}

function killDaemon() {
return daemonClient.stop();
async function killDaemon(): Promise<void> {
if (daemonClient.enabled()) {
return daemonClient.stop();
}
}

async function resetCloudClient() {
Expand Down

0 comments on commit e0b376a

Please sign in to comment.