summaryrefslogtreecommitdiff
path: root/std/node/_fs/_fs_writeFile.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/node/_fs/_fs_writeFile.ts')
-rw-r--r--std/node/_fs/_fs_writeFile.ts9
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;