summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/rt/30_fs.js2
-rw-r--r--cli/tests/unit/mkdir_test.ts31
2 files changed, 32 insertions, 1 deletions
diff --git a/cli/rt/30_fs.js b/cli/rt/30_fs.js
index 7faa2c392..7c7d81c3b 100644
--- a/cli/rt/30_fs.js
+++ b/cli/rt/30_fs.js
@@ -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;
diff --git a/cli/tests/unit/mkdir_test.ts b/cli/tests/unit/mkdir_test.ts
index 9ab6dc4d2..f2fe168e6 100644
--- a/cli/tests/unit/mkdir_test.ts
+++ b/cli/tests/unit/mkdir_test.ts
@@ -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");
+ },
+);