Skip to content

Commit

Permalink
adding reusable hook function
Browse files Browse the repository at this point in the history
  • Loading branch information
garysassano committed Jun 29, 2023
1 parent 40e73ec commit 1b57c17
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions apps/wing/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function main() {
});

program
.option("--no-progress", "Hide show compilation progress");
.option("--no-progress", "Hide show compilation progress")
.option("--no-update-check", "Skip checking for toolchain updates")
.hook("preAction", async (cmd) => {
const updateCheck = cmd.opts().updateCheck;
Expand All @@ -47,6 +47,14 @@ async function main() {
}
});

async function progressHook(cmd: Command) {
const target = cmd.opts().target;
const progress = program.opts().progress;
if (progress !== false && target !== "sim") {
process.env.PROGRESS = "1";
}
}

program
.command("run")
.alias("it")
Expand All @@ -66,13 +74,7 @@ async function main() {
.default("sim")
)
.option("-p, --plugins [plugin...]", "Compiler plugins")
.hook("preAction", async (cmd) => {
const target = cmd.opts().target;
const progress = program.opts().progress;
if (progress !== false && target !== "sim") {
process.env.PROGRESS = "1";
}
})
.hook("preAction", progressHook)
.action(actionErrorHandler(compile));

program
Expand All @@ -87,13 +89,7 @@ async function main() {
.default("sim")
)
.option("-p, --plugins [plugin...]", "Compiler plugins")
.hook("preAction", async (cmd) => {
const target = cmd.opts().target;
const progress = program.opts().progress;
if (progress !== false && target !== "sim") {
process.env.PROGRESS = "1";
}
})
.hook("preAction", progressHook)
.action(actionErrorHandler(test));

program.command("docs").description("Open the Wing documentation").action(docs);
Expand Down

0 comments on commit 1b57c17

Please sign in to comment.