mirror of
https://github.com/denoland/deno.git
synced 2025-10-02 15:14:33 +00:00
bug fix and tests for std/node/fs/mkdir (#4917)
This commit is contained in:
parent
fe5b151755
commit
516d970fd3
2 changed files with 33 additions and 1 deletions
|
@ -20,7 +20,7 @@ export function mkdir(
|
||||||
let recursive = false;
|
let recursive = false;
|
||||||
|
|
||||||
if (typeof options == "function") {
|
if (typeof options == "function") {
|
||||||
callback == options;
|
callback = options;
|
||||||
} else if (typeof options === "number") {
|
} else if (typeof options === "number") {
|
||||||
mode = options;
|
mode = options;
|
||||||
} else if (typeof options === "boolean") {
|
} else if (typeof options === "boolean") {
|
||||||
|
|
32
std/node/_fs/_fs_mkdir_test.ts
Normal file
32
std/node/_fs/_fs_mkdir_test.ts
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
import { assert } from "../../testing/asserts.ts";
|
||||||
|
import { mkdir, mkdirSync } from "./_fs_mkdir.ts";
|
||||||
|
import { existsSync } from "./_fs_exists.ts";
|
||||||
|
|
||||||
|
const { test } = Deno;
|
||||||
|
|
||||||
|
const tmpDir = "./tmpdir";
|
||||||
|
|
||||||
|
test({
|
||||||
|
name: "[node/fs] mkdir",
|
||||||
|
fn: async () => {
|
||||||
|
const result = await new Promise((resolve) => {
|
||||||
|
mkdir(tmpDir, (err) => {
|
||||||
|
err && resolve(false);
|
||||||
|
resolve(existsSync(tmpDir));
|
||||||
|
Deno.removeSync(tmpDir);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
assert(result);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
test({
|
||||||
|
name: "[node/fs] mkdirSync",
|
||||||
|
fn: () => {
|
||||||
|
mkdirSync(tmpDir);
|
||||||
|
assert(existsSync(tmpDir));
|
||||||
|
Deno.removeSync(tmpDir);
|
||||||
|
},
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue