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_copy.ts | |
parent | 7e32269f3f230c5b714bbf70aa59d74f9a867373 (diff) |
[std/node] add the ability to path argument to be URL type (#5055)
Diffstat (limited to 'std/node/_fs/_fs_copy.ts')
-rw-r--r-- | std/node/_fs/_fs_copy.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/std/node/_fs/_fs_copy.ts b/std/node/_fs/_fs_copy.ts index 0193e77c4..26d9a8c9a 100644 --- a/std/node/_fs/_fs_copy.ts +++ b/std/node/_fs/_fs_copy.ts @@ -1,17 +1,21 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { CallbackWithError } from "./_fs_common.ts"; +import { fromFileUrl } from "../path.ts"; export function copyFile( - source: string, + source: string | URL, destination: string, callback: CallbackWithError ): void { + source = source instanceof URL ? fromFileUrl(source) : source; + Deno.copyFile(source, destination) .then(() => callback()) .catch(callback); } -export function copyFileSync(source: string, destination: string): void { +export function copyFileSync(source: string | URL, destination: string): void { + source = source instanceof URL ? fromFileUrl(source) : source; Deno.copyFileSync(source, destination); } |