Skip to content

Commit

Permalink
fix: Add missing "junction" type for SymlinkOptions.types (#23756)
Browse files Browse the repository at this point in the history
Junction symlink support is added in #22762, but `SymlinkOptions` and
its documents are not updated.
  • Loading branch information
futsuuu committed May 14, 2024
1 parent 6084cf6 commit c0a6007
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/symlink_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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() {
Expand Down Expand Up @@ -96,6 +114,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() {
Expand Down

0 comments on commit c0a6007

Please sign in to comment.