-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell.ts
36 lines (31 loc) · 948 Bytes
/
shell.ts
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 "auto";
import { ExecaChildProcess } from "execa";
export default auto({
id: "shell",
title: "Shell-like usage",
run: async ({ project }) => {
cd(project.rootDirectory);
console.log((await execa("cat", ["package.json"]).pipeStdout?.(execa("grep", ["license"])))?.stdout);
const whoami = await $`whoami`;
await $`echo "Hello, ${whoami}"`.pipeStdout?.(process.stdout);
console.log(
(
await Promise.all(
[
async () => {
await sleep(100);
return $`echo "1"`.pipeStdout?.(process.stdout);
},
async () => {
await sleep(200);
return $`echo "2"`.pipeStdout?.(process.stdout);
},
].map((f) => f())
)
).map((p) => p?.stdout)
);
const name = "auto-foo-bar-baz";
await $`mkdir -p /tmp/${name}`;
console.log((await $`ls /tmp/${name}`).exitCode);
},
});