mirror of
https://github.com/denoland/deno.git
synced 2025-07-28 23:53:53 +00:00
Implement deno.mkdir()
This commit is contained in:
parent
e293c204a0
commit
c2663e1d82
9 changed files with 77 additions and 48 deletions
28
js/mkdir_test.ts
Normal file
28
js/mkdir_test.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import { test, testPerm, assert, assertEqual } from "./test_util.ts";
|
||||
import * as deno from "deno";
|
||||
|
||||
testPerm({ write: true }, function mkdirSyncSuccess() {
|
||||
const path = deno.makeTempDirSync() + "/dir/subdir";
|
||||
deno.mkdirSync(path);
|
||||
const pathInfo = deno.statSync(path);
|
||||
assert(pathInfo.isDirectory());
|
||||
});
|
||||
|
||||
testPerm({ write: false }, function mkdirSyncPerm() {
|
||||
let err;
|
||||
try {
|
||||
deno.mkdirSync("/baddir");
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
assertEqual(err.kind, deno.ErrorKind.PermissionDenied);
|
||||
assertEqual(err.name, "PermissionDenied");
|
||||
});
|
||||
|
||||
testPerm({ write: true }, async function mkdirSuccess() {
|
||||
const path = deno.makeTempDirSync() + "/dir/subdir";
|
||||
await deno.mkdir(path);
|
||||
const pathInfo = deno.statSync(path);
|
||||
assert(pathInfo.isDirectory());
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue