diff options
Diffstat (limited to 'std/node/_fs/_fs_mkdir.ts')
-rw-r--r-- | std/node/_fs/_fs_mkdir.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/std/node/_fs/_fs_mkdir.ts b/std/node/_fs/_fs_mkdir.ts index fd2156c37..a65db8dba 100644 --- a/std/node/_fs/_fs_mkdir.ts +++ b/std/node/_fs/_fs_mkdir.ts @@ -1,21 +1,23 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { CallbackWithError } from "./_fs_common.ts"; +import { fromFileUrl } from "../path.ts"; /** - * 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 */ -type Path = string; type MkdirOptions = | { recursive?: boolean; mode?: number | undefined } | number | boolean; export function mkdir( - path: Path, + path: string | URL, options?: MkdirOptions | CallbackWithError, callback?: CallbackWithError ): void { + path = path instanceof URL ? fromFileUrl(path) : path; + let mode = 0o777; let recursive = false; @@ -46,7 +48,8 @@ export function mkdir( }); } -export function mkdirSync(path: Path, options?: MkdirOptions): void { +export function mkdirSync(path: string | URL, options?: MkdirOptions): void { + path = path instanceof URL ? fromFileUrl(path) : path; let mode = 0o777; let recursive = false; |