mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
23 lines
649 B
JavaScript
23 lines
649 B
JavaScript
const { AsyncLocalStorage } = require("async_hooks");
|
|
const util = require("util");
|
|
const fs = require("fs");
|
|
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
|
|
// Test util.promisify with a built-in callback function
|
|
const readFilePromise = util.promisify(fs.readFile);
|
|
|
|
asyncLocalStorage.run({ test: "util.promisify" }, async () => {
|
|
try {
|
|
await readFilePromise(__filename, "utf8");
|
|
if (asyncLocalStorage.getStore()?.test !== "util.promisify") {
|
|
console.error("FAIL: util.promisify lost context");
|
|
process.exit(1);
|
|
}
|
|
process.exit(0);
|
|
} catch (err) {
|
|
console.error("ERROR:", err);
|
|
process.exit(1);
|
|
}
|
|
});
|