Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions packages/nx/bin/nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,19 @@ async function main() {
handleMissingLocalInstallation(workspace ? workspace.dir : null);
}

// Prompt for analytics preference if not set
try {
await ensureAnalyticsPreferenceSet();
} catch {}
await startAnalytics();

// this file is already in the local workspace
if (isNxCloudCommand(process.argv[2])) {
await initAnalytics();
// nx-cloud commands can run without local Nx installation
process.env.NX_DAEMON = 'false';
require('nx/src/command-line/nx-commands').commandsObject.argv;
} else if (isLocalInstall) {
await initAnalytics();
await initLocal(workspace);
} else if (localNx) {
// Nx is being run from globally installed CLI - hand off to the local
// Don't start analytics or connect to the DB here — the local Nx
// will handle it when it runs its own bin/nx.ts
warnIfUsingOutdatedGlobalInstall(GLOBAL_NX_VERSION, LOCAL_NX_VERSION);
if (localNx.includes('.nx')) {
const nxWrapperPath = localNx.replace(/\.nx.*/, '.nx/') + 'nxw.js';
Expand Down Expand Up @@ -211,6 +209,13 @@ function isNxCloudCommand(command: string): boolean {
return nxCloudCommands.includes(command);
}

async function initAnalytics() {
try {
await ensureAnalyticsPreferenceSet();
} catch {}
await startAnalytics();
}

function handleMissingLocalInstallation(detectedWorkspaceRoot: string | null) {
output.error({
title: detectedWorkspaceRoot
Expand Down
Loading