conditional
Execute a set of operations based on whether a specified condition evaluates to true or false.
Example
{
"op": "conditional",
"condition": "$useTypescript === 'true'",
"then": [
{
"op": "add",
"remoteSrc": "/templates/tsconfig.json",
"targetSrc": "./tsconfig.json"
}
],
"else": [
{
"op": "add",
"remoteSrc": "/templates/jsconfig.json",
"targetSrc": "./jsconfig.json"
}
]
}
Fields
Fields | Type | Description |
---|---|---|
op | 'conditional' | Specifies the type of operation. For ConditionalOperation, this field must be 'conditional'. |
condition | string | An expression that evaluates to a boolean value. This can include variables . |
then | Operation[] | An array of operations to execute if the condition evaluates to true. |
else | Operation[] (optional) | An array of operations to execute if the condition evaluates to false. |