Skip to content

Commit

Permalink
fix initial value for caption
Browse files Browse the repository at this point in the history
  • Loading branch information
hrgdavor committed Oct 15, 2023
1 parent ba0dc40 commit c38266e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,20 @@ const runScript = async ({ script, url, base=globalBase, root=base }) => {
def = combineParameterDefinitions(fromSource, await scriptModule.getParameterDefinitions?.())
main = scriptModule.main
const params = {}
def.forEach(({ name, initial, default: def }) => params[name] = def || initial)
def.forEach(({ name, initial, default: def, type, values, captions }) =>{
let val = def || initial
if(type === 'choice' && values.indexOf(v=>v === val) === -1){
// it is supported for choice to use default value from captions also
// but script will need the matching value
for(let i=0; i<captions.length; i++){
if(captions[i] === val){
val = values[i]
break;
}
}
}
params[name] = val
})
await runMain({ params })
return {def}
}
Expand Down

0 comments on commit c38266e

Please sign in to comment.