Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: util.promisify(fs.exists) always rejects #2408

Closed
kt3k opened this issue Jul 2, 2022 · 1 comment
Closed

node: util.promisify(fs.exists) always rejects #2408

kt3k opened this issue Jul 2, 2022 · 1 comment

Comments

@kt3k
Copy link
Member

kt3k commented Jul 2, 2022

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)
})
@cjihrig
Copy link
Contributor

cjihrig commented Jul 11, 2022

This was fixed in #2409. Closing.

@cjihrig cjihrig closed this as completed Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants