diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2020-05-23 04:11:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-22 22:11:10 -0400 |
commit | 7f81f02ce794ac14ca25d3505f339cb663499ce6 (patch) | |
tree | 3e84ef5d0b92315aebdf1f4d48439d507ce5bfae /std/node/_fs/_fs_writeFile.ts | |
parent | 28b651c2e2bbe590295077f9253a3feb084349fd (diff) |
std/node: fs.writeFile/sync path can now be an URL (#5652)
Diffstat (limited to 'std/node/_fs/_fs_writeFile.ts')
-rw-r--r-- | std/node/_fs/_fs_writeFile.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/std/node/_fs/_fs_writeFile.ts b/std/node/_fs/_fs_writeFile.ts index b46620d9b..72e75c97a 100644 --- a/std/node/_fs/_fs_writeFile.ts +++ b/std/node/_fs/_fs_writeFile.ts @@ -1,5 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { notImplemented } from "../_utils.ts"; +import { fromFileUrl } from "../path.ts"; import { WriteFileOptions, @@ -10,7 +11,7 @@ import { } from "./_fs_common.ts"; export function writeFile( - pathOrRid: string | number, + pathOrRid: string | number | URL, data: string | Uint8Array, optOrCallback: string | CallbackWithError | WriteFileOptions | undefined, callback?: CallbackWithError @@ -24,6 +25,8 @@ export function writeFile( throw new TypeError("Callback must be a function."); } + pathOrRid = pathOrRid instanceof URL ? fromFileUrl(pathOrRid) : pathOrRid; + const flag: string | undefined = isFileOptions(options) ? options.flag : undefined; @@ -65,10 +68,12 @@ export function writeFile( } export function writeFileSync( - pathOrRid: string | number, + pathOrRid: string | number | URL, data: string | Uint8Array, options?: string | WriteFileOptions ): void { + pathOrRid = pathOrRid instanceof URL ? fromFileUrl(pathOrRid) : pathOrRid; + const flag: string | undefined = isFileOptions(options) ? options.flag : undefined; |