summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts14
-rw-r--r--tests/unit/symlink_test.ts36
2 files changed, 43 insertions, 7 deletions
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index c940a6e61..09c669c28 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -5344,16 +5344,16 @@ declare namespace Deno {
*
* @category File System */
export interface SymlinkOptions {
- /** If the symbolic link should be either a file or directory. This option
- * only applies to Windows and is ignored on other operating systems. */
- type: "file" | "dir";
+ /** Specify the symbolic link type as file, directory or NTFS junction. This
+ * option only applies to Windows and is ignored on other operating systems. */
+ type: "file" | "dir" | "junction";
}
/**
* Creates `newpath` as a symbolic link to `oldpath`.
*
- * The `options.type` parameter can be set to `"file"` or `"dir"`. This
- * argument is only available on Windows and ignored on other platforms.
+ * The `options.type` parameter can be set to `"file"`, `"dir"` or `"junction"`.
+ * This argument is only available on Windows and ignored on other platforms.
*
* ```ts
* await Deno.symlink("old/name", "new/name");
@@ -5373,8 +5373,8 @@ declare namespace Deno {
/**
* Creates `newpath` as a symbolic link to `oldpath`.
*
- * The `options.type` parameter can be set to `"file"` or `"dir"`. This
- * argument is only available on Windows and ignored on other platforms.
+ * The `options.type` parameter can be set to `"file"`, `"dir"` or `"junction"`.
+ * This argument is only available on Windows and ignored on other platforms.
*
* ```ts
* Deno.symlinkSync("old/name", "new/name");
diff --git a/tests/unit/symlink_test.ts b/tests/unit/symlink_test.ts
index 310c36930..0ee4a36fd 100644
--- a/tests/unit/symlink_test.ts
+++ b/tests/unit/symlink_test.ts
@@ -40,6 +40,24 @@ Deno.test(
);
Deno.test(
+ {
+ ignore: Deno.build.os !== "windows",
+ permissions: { read: true, write: true },
+ },
+ function symlinkSyncJunction() {
+ const testDir = Deno.makeTempDirSync();
+ const oldname = testDir + "/oldname";
+ const newname = testDir + "/newname";
+ Deno.mkdirSync(oldname);
+ Deno.symlinkSync(oldname, newname, { type: "junction" });
+ const newNameInfoLStat = Deno.lstatSync(newname);
+ const newNameInfoStat = Deno.statSync(newname);
+ assert(newNameInfoLStat.isSymlink);
+ assert(newNameInfoStat.isDirectory);
+ },
+);
+
+Deno.test(
{ permissions: { read: false, write: false } },
function symlinkSyncPerm() {
assertThrows(() => {
@@ -97,6 +115,24 @@ Deno.test(
);
Deno.test(
+ {
+ ignore: Deno.build.os !== "windows",
+ permissions: { read: true, write: true },
+ },
+ async function symlinkJunction() {
+ const testDir = Deno.makeTempDirSync();
+ const oldname = testDir + "/oldname";
+ const newname = testDir + "/newname";
+ Deno.mkdirSync(oldname);
+ await Deno.symlink(oldname, newname, { type: "junction" });
+ const newNameInfoLStat = Deno.lstatSync(newname);
+ const newNameInfoStat = Deno.statSync(newname);
+ assert(newNameInfoLStat.isSymlink, "NOT SYMLINK");
+ assert(newNameInfoStat.isDirectory, "NOT DIRECTORY");
+ },
+);
+
+Deno.test(
{ permissions: { read: true, write: true } },
async function symlinkAlreadyExist() {
const existingFile = Deno.makeTempFileSync();