util.promisify works differently in node and deno_std/node when the fs.exists is passed to it.
The following code prints Error!!!\ntrue (assuming README.md exists in current dir)
import { promisify } from "https://deno.land/std@0.146.0/node/util.ts";
import { exists } from "https://deno.land/std@0.146.0/node/fs.ts";
const pExists = promisify(exists);
try {
const result = await pExists("README.md")
console.log("exists", result);
} catch(e) {
console.log("Error!!!");
console.log(e)
}
On the othe hand, the following prints Success\ntrue with node.js:
const util = require("util");
const fs = require("fs");
const pExists = util.promisify(fs.exists);
pExists("README.md").then(x => {
console.log("Success");
console.log(x)
}).catch((e) => {
console.log("Error!!!");
console.log(e)
})
util.promisifyworks differently in node anddeno_std/nodewhen the fs.exists is passed to it.The following code prints
Error!!!\ntrue(assuming README.md exists in current dir)On the othe hand, the following prints
Success\ntruewith node.js: