fix(cli): handle __flow suffix when deriving the flow's Windmill path

This commit is contained in:
hugocasa
2026-05-26 14:03:47 +02:00
parent 964182c0ab
commit 44762fff7f
+14 -1
View File
@@ -652,7 +652,7 @@ async function preview(
// the anchor for relative-import resolution: inline scripts in this flow are
// treated as living at "<flow_wm_path>/<step_id>", so "./util" resolves to
// "<flow_wm_path_parent>/util" — matching the keys in temp_script_refs.
const flowWmPath = flowPath.substring(0, flowPath.indexOf(".flow")).replaceAll(SEP, "/");
const flowWmPath = stripFlowSuffix(flowPath).replaceAll(SEP, "/");
if (opts.step) {
await previewStep(opts.step, localFlow, flowWmPath, workspace, input, tempScriptRefs, opts.silent);
@@ -797,6 +797,19 @@ async function previewStep(
}
}
// Strip the `.flow`/`__flow` directory suffix to recover the flow's logical
// Windmill path. Workspaces with nonDottedPaths use `__flow`; the default
// uses `.flow`. A previous version used `indexOf(".flow")` which returned -1
// (and thus `substring(0, -1) === ""`) for `__flow` folders and for the
// `dirname("flow.yaml") === "."` fallback — producing an empty path that
// broke relative-import resolution downstream.
function stripFlowSuffix(flowPath: string): string {
const stripped = flowPath.endsWith(SEP) ? flowPath.slice(0, -SEP.length) : flowPath;
if (stripped.endsWith(".flow")) return stripped.slice(0, -".flow".length);
if (stripped.endsWith("__flow")) return stripped.slice(0, -"__flow".length);
return stripped;
}
function findStepInFlowValue(flowValue: any, stepId: string): any | undefined {
if (!flowValue) return undefined;
if (flowValue.failure_module?.id === stepId) return flowValue.failure_module;