fix(plugin-workflow-loop): fix condition checking (#5634)

This commit is contained in:
Junyi 2024-11-12 12:25:51 +08:00 committed by GitHub
parent e42c480d85
commit 3f86115f84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,23 +111,21 @@ export default class extends Instruction {
job.set({ result: { looped: nextIndex } });
await processor.saveJob(job);
if (loop.config.condition) {
const { calculation, expression, continueOnFalse } = loop.config.condition ?? {};
if (calculation || expression) {
const condition = calculateCondition(loop, processor);
if (!condition && !continueOnFalse) {
job.set({
status: JOB_STATUS.RESOLVED,
result: { looped: nextIndex, broken: true },
});
return job;
}
}
}
const length = getTargetLength(target);
if (nextIndex < length) {
await processor.saveJob(job);
if (loop.config.condition) {
const { calculation, expression, continueOnFalse } = loop.config.condition ?? {};
if (calculation || expression) {
const condition = calculateCondition(loop, processor);
if (!condition && !continueOnFalse) {
job.set({
status: JOB_STATUS.RESOLVED,
result: { looped: nextIndex, broken: true },
});
return job;
}
}
}
await processor.run(branch, job);
return processor.exit();
} else {