Skip to content

Commit 994f0c6

Browse files
committed
Add deno runbook helpers
1 parent b430a81 commit 994f0c6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

ext/deno-runbook/mod.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Mod.ts for runbook-deno helpers
2+
// Default Setup
3+
// See deno dax module for capabilities, including $.request, retry, etc
4+
import {CommandBuilder, build$} from "https://deno.land/x/dax/mod.ts";
5+
6+
const commandBuilder = new CommandBuilder()
7+
.stdout("inheritPiped")
8+
.stderr("inheritPiped")
9+
.printCommand(true);
10+
11+
const $ = build$({ commandBuilder });
12+
13+
const sh = async (...args) => {
14+
const start = (new Date()).toISOString()
15+
performance.mark('command_start');
16+
const r = await $.raw`${args.join(" ")}`
17+
performance.mark('command_end')
18+
const end = (new Date()).toISOString()
19+
const measure = performance.measure('command', 'command_start', 'command_end')
20+
const timing = {duration_ms: measure.duration, start, end}
21+
const {stdout, stderr, code} = r
22+
await Deno.jupyter.broadcast("display_data", {
23+
data: { "application/json": {command: args.join(" "), exit_code: code, timing, stdout, stderr}},
24+
metadata: {},
25+
transient: { display_id: "progress" }
26+
});
27+
return r
28+
}
29+
30+
export { sh, $ }

0 commit comments

Comments
 (0)