text

Bun

Symbol

$.ShellPromise.text

text(encoding?: BufferEncoding): Promise<string>

Read from stdout as a string

Automatically calls quiet to disable echoing to stdout.

@param encoding

The encoding to use when decoding the output

@returns

A promise that resolves with stdout as a string

Read as UTF-8 string

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

Read as base64 string

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