1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

fix: Add missing "junction" type for SymlinkOptions.types (#23756)

Junction symlink support is added in #22762, but `SymlinkOptions` and
its documents are not updated.
This commit is contained in:
futsuuu 2024-05-14 22:06:21 +09:00 committed by GitHub
parent 6084cf60ba
commit c0a600786e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 7 deletions

View file

@ -5344,16 +5344,16 @@ declare namespace Deno {
* *
* @category File System */ * @category File System */
export interface SymlinkOptions { export interface SymlinkOptions {
/** If the symbolic link should be either a file or directory. This option /** Specify the symbolic link type as file, directory or NTFS junction. This
* only applies to Windows and is ignored on other operating systems. */ * option only applies to Windows and is ignored on other operating systems. */
type: "file" | "dir"; type: "file" | "dir" | "junction";
} }
/** /**
* Creates `newpath` as a symbolic link to `oldpath`. * Creates `newpath` as a symbolic link to `oldpath`.
* *
* The `options.type` parameter can be set to `"file"` or `"dir"`. This * The `options.type` parameter can be set to `"file"`, `"dir"` or `"junction"`.
* argument is only available on Windows and ignored on other platforms. * This argument is only available on Windows and ignored on other platforms.
* *
* ```ts * ```ts
* await Deno.symlink("old/name", "new/name"); * await Deno.symlink("old/name", "new/name");
@ -5373,8 +5373,8 @@ declare namespace Deno {
/** /**
* Creates `newpath` as a symbolic link to `oldpath`. * Creates `newpath` as a symbolic link to `oldpath`.
* *
* The `options.type` parameter can be set to `"file"` or `"dir"`. This * The `options.type` parameter can be set to `"file"`, `"dir"` or `"junction"`.
* argument is only available on Windows and ignored on other platforms. * This argument is only available on Windows and ignored on other platforms.
* *
* ```ts * ```ts
* Deno.symlinkSync("old/name", "new/name"); * Deno.symlinkSync("old/name", "new/name");

View file

@ -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( Deno.test(
{ permissions: { read: false, write: false } }, { permissions: { read: false, write: false } },
function symlinkSyncPerm() { function symlinkSyncPerm() {
@ -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( Deno.test(
{ permissions: { read: true, write: true } }, { permissions: { read: true, write: true } },
async function symlinkAlreadyExist() { async function symlinkAlreadyExist() {