Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
ShellPromise.finally method | Bun module | Bun BuildDocsReferenceGuidesBlogDiscord/Bun/$/ShellPromise/finallyMfinally BuildDocsReferenceGuidesBlogDiscord /Bun/$/ShellPromise/finallyMfinally $.ShellPromise.finallyfinally(onfinally?: null | () => void): PromiseShellOutput>; @param onfinally @returns Referenced typesinterface ShellOutputreadonly exitCode: numberreadonly stderr: Bufferreadonly stdout: BufferarrayBuffer(): ArrayBuffer; @returns blob(): Blob; @returns bytes(): Uint8ArrayArrayBuffer>; @returns json(): any; @returns text(encoding?: BufferEncoding): string; @param encoding @returns
Search the reference...
/
method
The callback to execute when the Promise is settled (fulfilled or rejected).
A Promise for the completion of the callback.
Read from stdout as an ArrayBuffer
Stdout as an ArrayBuffer
const output = await $`echo hello`;
console.log(output.arrayBuffer()); // ArrayBuffer { byteLength: 6 }
Read from stdout as a Blob
Stdout as a blob
const output = await $`echo hello`;
console.log(output.blob()); // Blob { size: 6, type: "" }
Read from stdout as an Uint8Array
Stdout as an Uint8Array
const output = await $`echo hello`;
console.log(output.bytes()); // Uint8Array { byteLength: 6 }
Read from stdout as a JSON object
Stdout as a JSON object
const output = await $`echo '{"hello": 123}'`;
console.log(output.json()); // { hello: 123 }
Read from stdout as a string
The encoding to use when decoding the output
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"
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →ShellPromise.finally method | Bun module | Bun,AI智能索引,全网链接索引,智能导航,网页索引
- API documentation for method bun.$.ShellPromise.finally | Bun