text

Bun

Symbol

$.ShellOutput.text

text(encoding?: BufferEncoding): string

Read from stdout as a string

@param encoding

The encoding to use when decoding the output

@returns

Stdout as a string with the given encoding

Read as UTF-8 string

const output = await $`echo hello`;
console.log(output.text()); // "hello\n"

Read as base64 string

const output = await $`echo ${atob("hello")}`;
console.log(output.text("base64")); // "hello\n"