stream the output dynamically
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
Sam Therapy 2022-12-06 18:23:04 +01:00
parent 2082460f81
commit feab29e592
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD
2 changed files with 8 additions and 12 deletions

View file

@ -4,7 +4,7 @@ FROM denoland/deno:1.28.3 as base
RUN deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no-check -r -f https://deno.land/x/deploy/deployctl.ts
COPY run.ts /bin/
RUN chmod +x /bin/run.ts
RUN chmod +x /bin/run.ts && deno cache /bin/run.ts
USER deno
CMD ["/bin/run.ts"]

18
run.ts
View file

@ -1,5 +1,7 @@
#!/usr/bin/env -S deno run --allow-run --allow-env --no-lock
import { copy } from "https://deno.land/std@0.104.0/io/util.ts";
const env = Deno.env.toObject();
if (!env["PLUGIN_DENO_DEPLOY_TOKEN"] && !env["DENO_DEPLOY_TOKEN"]) {
@ -63,20 +65,14 @@ const prog = Deno.run({
});
// TODO: make this dynamic?
const [status, stdout, stderr] = await Promise.all([
prog.status(),
prog.output(),
prog.stderrOutput(),
]);
const status = await prog.status()
copy(prog.stdout, Deno.stdout);
copy(prog.stderr, Deno.stderr);
prog.close();
const std = new TextDecoder().decode(stdout);
const err = new TextDecoder().decode(stderr);
console.log(std);
if (!status.success) {
console.error("Deno Deploy failed!");
console.log(err);
Deno.exit(1);
}