diff options
| author | River <22485304+actual-size@users.noreply.github.com> | 2020-06-12 02:36:20 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-11 12:36:20 -0400 |
| commit | 818a8010928cb8cef0b7043bd881c8cdce9b6efc (patch) | |
| tree | 1502e74c9eb01901df8da118257d60d4f962b0e4 /cli/js/ops/fs/stat.ts | |
| parent | 813210d4337bf6e174f1da1f1a6c6fb9b073afa2 (diff) | |
feat: URL support in Deno filesystem methods (#5990)
Diffstat (limited to 'cli/js/ops/fs/stat.ts')
| -rw-r--r-- | cli/js/ops/fs/stat.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cli/js/ops/fs/stat.ts b/cli/js/ops/fs/stat.ts index e8fd28218..93d31fc3f 100644 --- a/cli/js/ops/fs/stat.ts +++ b/cli/js/ops/fs/stat.ts @@ -1,6 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { sendSync, sendAsync } from "../dispatch_json.ts"; import { build } from "../../build.ts"; +import { pathFromURL } from "../../util.ts"; export interface FileInfo { size: number; @@ -65,7 +66,8 @@ export function parseFileInfo(response: StatResponse): FileInfo { }; } -export async function lstat(path: string): Promise<FileInfo> { +export async function lstat(path: string | URL): Promise<FileInfo> { + path = pathFromURL(path); const res = (await sendAsync("op_stat", { path, lstat: true, @@ -73,7 +75,8 @@ export async function lstat(path: string): Promise<FileInfo> { return parseFileInfo(res); } -export function lstatSync(path: string): FileInfo { +export function lstatSync(path: string | URL): FileInfo { + path = pathFromURL(path); const res = sendSync("op_stat", { path, lstat: true, @@ -81,7 +84,8 @@ export function lstatSync(path: string): FileInfo { return parseFileInfo(res); } -export async function stat(path: string): Promise<FileInfo> { +export async function stat(path: string | URL): Promise<FileInfo> { + path = pathFromURL(path); const res = (await sendAsync("op_stat", { path, lstat: false, @@ -89,7 +93,8 @@ export async function stat(path: string): Promise<FileInfo> { return parseFileInfo(res); } -export function statSync(path: string): FileInfo { +export function statSync(path: string | URL): FileInfo { + path = pathFromURL(path); const res = sendSync("op_stat", { path, lstat: false, |
