generateCode作为模块代码

This commit is contained in:
fofolee
2024-12-28 12:39:22 +08:00
parent 1dafacf3f1
commit 41484991ab
2 changed files with 26 additions and 23 deletions

View File

@@ -0,0 +1,21 @@
export function generateCode(commandFlow) {
let code = [];
commandFlow.forEach((cmd) => {
let line = "";
if (cmd.outputVariable) {
line += `let ${cmd.outputVariable} = `;
}
if (cmd.value === "ubrowser") {
line += cmd.argv;
} else {
line += `${cmd.value}(${cmd.argv})`;
}
code.push(line);
});
return code.join("\n");
}