Slide 45
Slide 45 text
軽量化が進んで組み込みやすくなっている
インメモリでShell, File Systemをエミュレートするライブラリ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const hello = defineCommand("hello", async (args, ctx) => {
const name = args[0] || "world";
return { stdout: `Hello, ${name}!\n`, stderr: "", exitCode: 0 };
});
const upper = defineCommand("upper", async (args, ctx) => {
// ctx.stdin is a ByteString — decode to text before string ops.
return {
stdout: decodeBytesToUtf8(ctx.stdin).toUpperCase(),
stderr: "",
exitCode: 0,
};
});
const bash = new Bash({ customCommands: [hello, upper] });
await bash.exec("hello Alice"); // "Hello, Alice!\n"
await bash.exec("echo 'test' | upper"); // "TEST\n"
https://justbash.dev/