diff options
author | Ali Hasani <a.hassssani@gmail.com> | 2020-05-03 23:44:38 +0430 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-03 15:14:38 -0400 |
commit | 5cc0f056d1af6f76c6ad81a6cd68dcaabba60f35 (patch) | |
tree | 4a32cb418ca84aba47e05e6dc6c98e8ef724fcd0 /std/node/_fs/_fs_chmod.ts | |
parent | 7e32269f3f230c5b714bbf70aa59d74f9a867373 (diff) |
[std/node] add the ability to path argument to be URL type (#5055)
Diffstat (limited to 'std/node/_fs/_fs_chmod.ts')
-rw-r--r-- | std/node/_fs/_fs_chmod.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/std/node/_fs/_fs_chmod.ts b/std/node/_fs/_fs_chmod.ts index 2adff59ff..b1079e0a1 100644 --- a/std/node/_fs/_fs_chmod.ts +++ b/std/node/_fs/_fs_chmod.ts @@ -1,28 +1,32 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { CallbackWithError } from "./_fs_common.ts"; +import { fromFileUrl } from "../path.ts"; const allowedModes = /^[0-7]{3}/; /** - * TODO: Also accept 'path' parameter as a Node polyfill Buffer or URL type once these + * TODO: Also accept 'path' parameter as a Node polyfill Buffer type once these * are implemented. See https://github.com/denoland/deno/issues/3403 */ export function chmod( - path: string, + path: string | URL, mode: string | number, callback: CallbackWithError ): void { + path = path instanceof URL ? fromFileUrl(path) : path; + Deno.chmod(path, getResolvedMode(mode)) .then(() => callback()) .catch(callback); } /** - * TODO: Also accept 'path' parameter as a Node polyfill Buffer or URL type once these + * TODO: Also accept 'path' parameter as a Node polyfill Buffer type once these * are implemented. See https://github.com/denoland/deno/issues/3403 */ -export function chmodSync(path: string, mode: string | number): void { +export function chmodSync(path: string | URL, mode: string | number): void { + path = path instanceof URL ? fromFileUrl(path) : path; Deno.chmodSync(path, getResolvedMode(mode)); } |