@@ -231,13 +231,38 @@ export async function runAddCommand(
231231 official [ addonId ] ??= { } ;
232232
233233 const optionEntries = Object . entries ( details . options ) ;
234+ const specifiedOptionsObject = Object . fromEntries (
235+ specifiedOptions . map ( ( option ) => option . split ( ':' , 2 ) )
236+ ) ;
234237 for ( const option of specifiedOptions ) {
235238 let [ optionId , optionValue ] = option . split ( ':' , 2 ) ;
236239
237240 // validates that the option exists
238- const optionEntry = optionEntries . find (
239- ( [ id , question ] ) => id === optionId || question . group === optionId
240- ) ;
241+ const optionEntry = optionEntries . find ( ( [ id , question ] ) => {
242+ // simple ID match
243+ if ( id === optionId ) return true ;
244+
245+ // group match - need to check conditions and value validity
246+ if ( question . group === optionId ) {
247+ // does the value exist for this option?
248+ if ( question . type === 'select' || question . type === 'multiselect' ) {
249+ const isValidValue = question . options . some ( ( opt ) => opt . value === optionValue ) ;
250+ if ( ! isValidValue ) return false ;
251+ }
252+
253+ // if there's a condition, does it pass?
254+ if ( question . condition ) {
255+ return question . condition ( specifiedOptionsObject ) ;
256+ }
257+
258+ // finally, unconditional
259+ return true ;
260+ }
261+
262+ // unrecognized optionId
263+ return false ;
264+ } ) ;
265+
241266 if ( ! optionEntry ) {
242267 const { choices } = getOptionChoices ( details ) ;
243268 throw new Error (
0 commit comments