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:
parent
5af1dcfe29
commit
60cd7695ef
2 changed files with 32 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue