Skip to content

Commit 8604913

Browse files
HosnainRafiHosnainRafi
authored andcommitted
fix: suppress spinner in netlify watch with --silent or --json flag
The netlify watch command shows an animated spinner while waiting for deploys to complete. This is annoying for users who switch away from the terminal (e.g., in tmux) since the spinner constantly updates and marks the window as having new output even though nothing useful changed. This PR suppresses the spinner when --silent or --json is passed, allowing users to run netlify watch --silent for a quiet mode that only prints when a deploy completes. Fixes #5301
1 parent 7e40a98 commit 8604913

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/commands/watch/watch.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const BUILD_FINISH_INTERVAL = 1e3
1515
// 20 minutes
1616
const BUILD_FINISH_TIMEOUT = 12e5
1717

18-
const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spinner: Spinner) {
18+
const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spinner: Spinner | undefined) {
1919
let firstPass = true
2020

2121
const waitForBuildToFinish = async function () {
@@ -27,7 +27,11 @@ const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spin
2727
// @TODO implement build error messages into this
2828

2929
if (!currentBuilds || currentBuilds.length === 0) {
30-
stopSpinner({ spinner })
30+
if (spinner) {
31+
stopSpinner({ spinner })
32+
} else {
33+
log('Waiting for active project deploys to complete... done')
34+
}
3135
return true
3236
}
3337
firstPass = false
@@ -46,7 +50,7 @@ const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spin
4650
return firstPass
4751
}
4852

49-
export const watch = async (_options: unknown, command: BaseCommand) => {
53+
export const watch = async (options: { silent?: boolean; json?: boolean }, command: BaseCommand) => {
5054
await command.authenticate()
5155
const client = command.netlify.api
5256
let siteId = command.netlify.site.id
@@ -80,7 +84,11 @@ export const watch = async (_options: unknown, command: BaseCommand) => {
8084
// "created_at": "2018-07-17T17:14:03.423Z"
8185
// }
8286
//
83-
const spinner = startSpinner({ text: 'Waiting for active project deploys to complete' })
87+
// Allow suppressing the spinner via --silent or --json (see #5301)
88+
const suppressSpinner = options?.silent || options?.json
89+
const spinner = suppressSpinner
90+
? undefined
91+
: startSpinner({ text: 'Waiting for active project deploys to complete' })
8492
try {
8593
// Fetch all builds!
8694
// const builds = await client.listSiteBuilds({siteId})

0 commit comments

Comments
 (0)