From 1ae8218afc7a51d9039bb7b1b081983f14fbd3f9 Mon Sep 17 00:00:00 2001 From: Dominic Saadi Date: Wed, 13 Jul 2022 00:13:14 +0900 Subject: [PATCH] fix: temporarily disable telemetry on windows (#5899) Co-authored-by: Daniel Choudhury --- packages/telemetry/src/telemetry.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/telemetry/src/telemetry.ts b/packages/telemetry/src/telemetry.ts index b06ff6d33ff0..cd863cd7a218 100644 --- a/packages/telemetry/src/telemetry.ts +++ b/packages/telemetry/src/telemetry.ts @@ -1,4 +1,5 @@ import { spawn } from 'child_process' +import os from 'node:os' import path from 'path' import { getPaths } from '@redwoodjs/internal' @@ -43,8 +44,14 @@ export const timedTelemetry = async ( return result } +// Returns 'Windows_NT' on Windows. +// See https://nodejs.org/docs/latest-v12.x/api/os.html#os_os_type. +const isWindows = os.type() === 'Windows_NT' + export const errorTelemetry = async (argv: Array, error: any) => { - if (process.env.REDWOOD_DISABLE_TELEMETRY) { + // FIXME: on Windows, cmd opens and closes a few times. + // See https://github.com/redwoodjs/redwood/issues/5728. + if (isWindows || process.env.REDWOOD_DISABLE_TELEMETRY) { return } @@ -53,7 +60,9 @@ export const errorTelemetry = async (argv: Array, error: any) => { // used as yargs middleware when any command is invoked export const telemetryMiddleware = async () => { - if (process.env.REDWOOD_DISABLE_TELEMETRY) { + // FIXME: on Windows, cmd opens and closes a few times. + // See https://github.com/redwoodjs/redwood/issues/5728. + if (isWindows || process.env.REDWOOD_DISABLE_TELEMETRY) { return }