From 5cc0f056d1af6f76c6ad81a6cd68dcaabba60f35 Mon Sep 17 00:00:00 2001 From: Ali Hasani Date: Sun, 3 May 2020 23:44:38 +0430 Subject: [std/node] add the ability to path argument to be URL type (#5055) --- std/node/_fs/_fs_copy.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'std/node/_fs/_fs_copy.ts') 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); } -- cgit v1.2.3