Deno: URL support for Deno FS methods

Created on 28 May 2020  路  4Comments  路  Source: denoland/deno

I would like to be able to do something like that:

await Deno.open(new URL('../relative/path.txt', import.meta.url));

Currently this fails the TypeScript type checking, and even when bypassing it, it throws a NotFound: No such file or directory (os error 2) error.

FWIW Node.js fs module methods support it, and IMO it would be a neat addition to Deno.

cli feat

Most helpful comment

in case of support for accepting URL type argument in fs methods, it should be an easy fix if Deno decides to have.
I think @marcosc90 is working on it as stated in this comment.

_However, it is now available with fromFileUrl function from path module._

import { fromFileUrl } from "http://deno.land/[email protected]/path/mod.ts";
await Deno.open(fromFileUrl(new URL("../relative/path.txt", import.meta.url)));

All 4 comments

in case of support for accepting URL type argument in fs methods, it should be an easy fix if Deno decides to have.
I think @marcosc90 is working on it as stated in this comment.

_However, it is now available with fromFileUrl function from path module._

import { fromFileUrl } from "http://deno.land/[email protected]/path/mod.ts";
await Deno.open(fromFileUrl(new URL("../relative/path.txt", import.meta.url)));

I'm currently working on https://github.com/denoland/deno/issues/4877 so I don't mind if someone else picks it up.

I'm all for it. We should be using URLs as much as possible.

I'm pretty green but I'd like to give this a shot

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benjamingr picture benjamingr  路  3Comments

davidbarratt picture davidbarratt  路  3Comments

sh7dm picture sh7dm  路  3Comments

ry picture ry  路  3Comments

justjavac picture justjavac  路  3Comments