Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
timonson committed Mar 20, 2024
1 parent 37d773b commit 95ab87f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion functions/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ export function ensureSymlinkedDirectorySync(
if (subDirectory) {
const joinedPath = securePath(directoryPathTo)(subDirectory!);
Deno.mkdirSync(joinedPath, { recursive: true });
return joinedPath;
} else {
return directoryPathTo;
}
return directoryPathTo;
}

export function ensureSymlinkedParentDirectorySync(
Expand Down
10 changes: 8 additions & 2 deletions functions/fs_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assertEquals, assertThrows } from "../test_deps.ts";
import { join } from "./deps.ts";
import {
ensureSymlinkedDataDirectorySync,
ensureSymlinkedDirectorySync,
Expand Down Expand Up @@ -74,6 +75,10 @@ Deno.test("Correctly handles subdirectory creation in the symlinked directory",
true,
"Subdirectory should exist within the symlinked directory",
);
assertEquals(
resultPath,
join(targetDir, subDirName),
);

cleanup(sourceDir);
cleanup(targetDir);
Expand All @@ -97,10 +102,11 @@ Deno.test("Throws an error when the source is not a directory", () => {
Deno.test("Creates a symlink between parent and child directory", () => {
const sourceDir = resolveMainModule("../.data");
const targetDir = resolveMainModule("./.data");
const result = ensureSymlinkedDataDirectorySync("file");
const subdirectory = "dir";
const result = ensureSymlinkedDataDirectorySync(subdirectory);
assertEquals(existsSync(targetDir), true);
assertEquals(Deno.lstatSync(targetDir).isSymlink, true);
assertEquals(result, targetDir);
assertEquals(result, join(targetDir, subdirectory));

cleanup(targetDir);
cleanup(sourceDir);
Expand Down

0 comments on commit 95ab87f

Please sign in to comment.