Skip to content

Commit

Permalink
feat: Add logging (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
Natoandro authored Nov 5, 2023
1 parent 0553628 commit f3dddec
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ function build() {
const args = ["build"];
if (release) args.push("--release");
args.push(...flags["--"]);
const proc = new Deno.Command("cargo", { args });
console.log(
"[deno_bindgen] Command:",
["cargo", ...args].map((s) => JSON.stringify(s)).join(" "),
);
const proc = new Deno.Command("cargo", { args, stderr: "inherit" });
return proc.output();
}

Expand All @@ -38,6 +42,7 @@ async function generate() {
try {
conf = JSON.parse(await Deno.readTextFile(metafile));
} catch (_) {
console.log(`[deno_bindgen] metafile not found at '${metafile}'`);
// Nothing to update.
return;
}
Expand Down Expand Up @@ -74,13 +79,21 @@ try {
// no op
}

console.log("[deno_bindgen] Building...");
const status = await build().catch((_) => Deno.removeSync(metafile));
if (status?.success || typeof flags.release == "string") {
await generate();
if (source) {
await ensureDir("bindings");
await Deno.writeTextFile("bindings/bindings.ts", source);
console.log("[deno_bindgen] Written at 'bindings/bindings.ts'");
} else {
console.log(
"[deno_bindgen] bindings.ts not generated: nothing to generate",
);
}
} else {
console.log("[deno_bindgen] Build failed with code", status?.code);
}

Deno.exit(status?.code || 0);

0 comments on commit f3dddec

Please sign in to comment.