1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix(cli): handle URL paths in Deno.mkdir() (#8140)

This commit is contained in:
Ross Weir 2020-10-27 23:21:32 +11:00 committed by GitHub
parent 5af1dcfe29
commit 60cd7695ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View file

@ -77,7 +77,7 @@
}
function mkdirArgs(path, options) {
const args = { path, recursive: false };
const args = { path: pathFromURL(path), recursive: false };
if (options != null) {
if (typeof options.recursive == "boolean") {
args.recursive = options.recursive;

View file

@ -4,6 +4,7 @@ import {
assertEquals,
assertThrows,
assertThrowsAsync,
pathToAbsoluteFileUrl,
unitTest,
} from "./test_util.ts";
@ -197,3 +198,33 @@ unitTest(
}
},
);
unitTest(
{ perms: { read: true, write: true } },
function mkdirSyncRelativeUrlPath(): void {
const testDir = Deno.makeTempDirSync();
const nestedDir = testDir + "/nested";
// Add trailing slash so base path is treated as a directory. pathToAbsoluteFileUrl removes trailing slashes.
const path = new URL("../dir", pathToAbsoluteFileUrl(nestedDir) + "/");
Deno.mkdirSync(nestedDir);
Deno.mkdirSync(path);
assertDirectory(testDir + "/dir");
},
);
unitTest(
{ perms: { read: true, write: true } },
async function mkdirRelativeUrlPath(): Promise<void> {
const testDir = Deno.makeTempDirSync();
const nestedDir = testDir + "/nested";
// Add trailing slash so base path is treated as a directory. pathToAbsoluteFileUrl removes trailing slashes.
const path = new URL("../dir", pathToAbsoluteFileUrl(nestedDir) + "/");
await Deno.mkdir(nestedDir);
await Deno.mkdir(path);
assertDirectory(testDir + "/dir");
},
);