@@ -13,6 +13,7 @@ import {
1313 defaultOnWarn ,
1414 generatedCodePresets ,
1515 GenericConfigObject ,
16+ objectifyOption ,
1617 objectifyOptionWithPresets ,
1718 treeshakePresets ,
1819 warnUnknownOptions
@@ -135,7 +136,7 @@ function mergeInputOptions(
135136 'treeshake' ,
136137 objectifyOptionWithPresets ( treeshakePresets , 'treeshake' , 'false, true, ' )
137138 ) ,
138- watch : getWatch ( config , overrides , 'watch' )
139+ watch : getWatch ( config , overrides )
139140 } ;
140141
141142 warnUnknownOptions (
@@ -171,8 +172,7 @@ const getObjectOption = (
171172 config : GenericConfigObject ,
172173 overrides : GenericConfigObject ,
173174 name : string ,
174- objectifyValue : ( value : unknown ) => Record < string , unknown > | undefined = value =>
175- ( typeof value === 'object' ? value : { } ) as Record < string , unknown > | undefined
175+ objectifyValue = objectifyOption
176176) => {
177177 const commandOption = normalizeObjectOptionValue ( overrides [ name ] , objectifyValue ) ;
178178 const configOption = normalizeObjectOptionValue ( config [ name ] , objectifyValue ) ;
@@ -182,8 +182,18 @@ const getObjectOption = (
182182 return configOption ;
183183} ;
184184
185- const getWatch = ( config : GenericConfigObject , overrides : GenericConfigObject , name : string ) =>
186- config . watch !== false && getObjectOption ( config , overrides , name ) ;
185+ export const getWatch = ( config : GenericConfigObject , overrides : GenericConfigObject ) =>
186+ config . watch !== false && getObjectOption ( config , overrides , 'watch' ) ;
187+
188+ export const isWatchEnabled = ( optionValue : unknown ) : boolean => {
189+ if ( Array . isArray ( optionValue ) ) {
190+ return optionValue . reduce (
191+ ( result , value ) => ( typeof value === 'boolean' ? value : result ) ,
192+ false
193+ ) ;
194+ }
195+ return optionValue === true ;
196+ } ;
187197
188198export const normalizeObjectOptionValue = (
189199 optionValue : unknown ,
0 commit comments