docs-util: fix parsing when function if it has three parameters (#10878)
* docs-util: fix parsing when step when it has three parameters * fix condition
This commit is contained in:
1 parent
a0e944a7a8
commit
46f987e351
6 files changed
+106960
-106544
No files matched your search
@@ -227,6 +227,7 @@ class WorkflowsPlugin {
|
||||
...resources,
|
||||
"workflow",
|
||||
])
|
||||
|
||||
this.updateWorkflowsTagsMap(workflowId, uniqueResources)
|
||||
}
|
||||
|
||||
@@ -379,10 +380,16 @@ class WorkflowsPlugin {
|
||||
.expression as ts.CallExpression
|
||||
const thenInitializer = initializer
|
||||
|
||||
const validArgumentsLength =
|
||||
whenInitializer.arguments.length === 2 ||
|
||||
whenInitializer.arguments.length === 3
|
||||
|
||||
const conditionIndex = whenInitializer.arguments.length - 1
|
||||
|
||||
if (
|
||||
whenInitializer.arguments.length < 2 ||
|
||||
(!ts.isFunctionExpression(whenInitializer.arguments[1]) &&
|
||||
!ts.isArrowFunction(whenInitializer.arguments[1])) ||
|
||||
!validArgumentsLength ||
|
||||
(!ts.isFunctionExpression(whenInitializer.arguments[conditionIndex]) &&
|
||||
!ts.isArrowFunction(whenInitializer.arguments[conditionIndex])) ||
|
||||
thenInitializer.arguments.length < 1 ||
|
||||
(!ts.isFunctionExpression(thenInitializer.arguments[0]) &&
|
||||
!ts.isArrowFunction(thenInitializer.arguments[0]))
|
||||
@@ -392,7 +399,8 @@ class WorkflowsPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
const whenCondition = whenInitializer.arguments[1].body.getText()
|
||||
const whenCondition =
|
||||
whenInitializer.arguments[conditionIndex].body.getText()
|
||||
|
||||
const thenStatements = (thenInitializer.arguments[0].body as ts.Block)
|
||||
.statements
|
||||
|
||||
Reference in new issue
Block a user