@@ -5,6 +5,7 @@ import prettyjson from 'prettyjson'
55import { type Spinner , startSpinner , stopSpinner } from '../../lib/spinner.js'
66import { chalk , logAndThrowError , log } from '../../utils/command-helpers.js'
77import type BaseCommand from '../base-command.js'
8+ import type { BaseOptionValues } from '../base-command.js'
89import { init } from '../init/init.js'
910
1011// 1 second
@@ -15,7 +16,7 @@ const BUILD_FINISH_INTERVAL = 1e3
1516// 20 minutes
1617const BUILD_FINISH_TIMEOUT = 12e5
1718
18- const waitForBuildFinish = async function ( api : NetlifyAPI , siteId : string , spinner : Spinner ) {
19+ const waitForBuildFinish = async function ( api : NetlifyAPI , siteId : string , spinner ? : Spinner ) {
1920 let firstPass = true
2021
2122 const waitForBuildToFinish = async function ( ) {
@@ -27,7 +28,9 @@ const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spin
2728 // @TODO implement build error messages into this
2829
2930 if ( ! currentBuilds || currentBuilds . length === 0 ) {
30- stopSpinner ( { spinner } )
31+ if ( spinner ) {
32+ stopSpinner ( { spinner } )
33+ }
3134 return true
3235 }
3336 firstPass = false
@@ -46,7 +49,7 @@ const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spin
4649 return firstPass
4750}
4851
49- export const watch = async ( _options : unknown , command : BaseCommand ) => {
52+ export const watch = async ( options : BaseOptionValues , command : BaseCommand ) => {
5053 await command . authenticate ( )
5154 const client = command . netlify . api
5255 let siteId = command . netlify . site . id
@@ -57,6 +60,8 @@ export const watch = async (_options: unknown, command: BaseCommand) => {
5760 siteId = siteData . id
5861 }
5962
63+ const isSilent = options . silent
64+
6065 // wait for 1 sec for everything to kickoff
6166 console . time ( 'Deploy time' )
6267 await new Promise ( ( resolve ) => {
@@ -80,7 +85,12 @@ export const watch = async (_options: unknown, command: BaseCommand) => {
8085 // "created_at": "2018-07-17T17:14:03.423Z"
8186 // }
8287 //
83- const spinner = startSpinner ( { text : 'Waiting for active project deploys to complete' } )
88+
89+ let spinner
90+ if ( ! isSilent ) {
91+ spinner = startSpinner ( { text : 'Waiting for active project deploys to complete' } )
92+ }
93+
8494 try {
8595 // Fetch all builds!
8696 // const builds = await client.listSiteBuilds({siteId})
0 commit comments