-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ts
More file actions
36 lines (28 loc) · 1.06 KB
/
example.ts
File metadata and controls
36 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { iter } from "https://deno.land/std@0.104.0/io/util.ts";
import { snap } from "./mod.ts";
// deno run -A --unstable ./example.ts
export async function runPrompt(): Promise<string> {
const process = Deno.run({
stdin: "piped",
stdout: "piped",
cmd: [
"powershell", "kopo", "search", "charmd", "-e",
],
/* env: {
NO_COLOR: "true",
},clearEnv:true */
});
let result = '';
process.stdin.write(new TextEncoder().encode('')).then(async _ => {await process.stdin.write(new TextEncoder().encode('\u0003'));/* Simulate CTRL+C */});
for await (let a of iter(process.stdout)) {
result += new TextDecoder().decode(a);
}
process.stdin.close();
process.stdout.close();
process.close();
return result;
}
const res = await runPrompt();
await snap([
{content: `\x1b[42m \x1b[1m\x1b[37mSnapper\x1b[39m\x1b[22m 📷 \x1b[49m`, imageSavePath: 'snapper.png', viewport: {width: 145, height: 35}},
], /*{ puppeteerLaunchOptions: {headless: false}, theme: {background: "#ccc"}}*/);