From c52d42590cd25163b6ed6c10d16ac035fc03e234 Mon Sep 17 00:00:00 2001 From: Emmanuel Valentin Date: Tue, 11 Nov 2025 00:43:56 -0600 Subject: [PATCH] feat: suppress spinner in watch command with --silent flag --- src/commands/watch/watch.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/commands/watch/watch.ts b/src/commands/watch/watch.ts index da36642468b..753ef07c2f5 100644 --- a/src/commands/watch/watch.ts +++ b/src/commands/watch/watch.ts @@ -5,6 +5,7 @@ import prettyjson from 'prettyjson' import { type Spinner, startSpinner, stopSpinner } from '../../lib/spinner.js' import { chalk, logAndThrowError, log } from '../../utils/command-helpers.js' import type BaseCommand from '../base-command.js' +import type { BaseOptionValues } from '../base-command.js' import { init } from '../init/init.js' // 1 second @@ -15,7 +16,7 @@ const BUILD_FINISH_INTERVAL = 1e3 // 20 minutes const BUILD_FINISH_TIMEOUT = 12e5 -const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spinner: Spinner) { +const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spinner?: Spinner) { let firstPass = true const waitForBuildToFinish = async function () { @@ -27,7 +28,9 @@ const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spin // @TODO implement build error messages into this if (!currentBuilds || currentBuilds.length === 0) { - stopSpinner({ spinner }) + if (spinner) { + stopSpinner({ spinner }) + } return true } firstPass = false @@ -46,7 +49,7 @@ const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spin return firstPass } -export const watch = async (_options: unknown, command: BaseCommand) => { +export const watch = async (options: BaseOptionValues, command: BaseCommand) => { await command.authenticate() const client = command.netlify.api let siteId = command.netlify.site.id @@ -57,6 +60,8 @@ export const watch = async (_options: unknown, command: BaseCommand) => { siteId = siteData.id } + const isSilent = options.silent + // wait for 1 sec for everything to kickoff console.time('Deploy time') await new Promise((resolve) => { @@ -80,7 +85,12 @@ export const watch = async (_options: unknown, command: BaseCommand) => { // "created_at": "2018-07-17T17:14:03.423Z" // } // - const spinner = startSpinner({ text: 'Waiting for active project deploys to complete' }) + + let spinner + if (!isSilent) { + spinner = startSpinner({ text: 'Waiting for active project deploys to complete' }) + } + try { // Fetch all builds! // const builds = await client.listSiteBuilds({siteId})