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

fix(ext/node): support junction symlinks on Windows (#22762)

Fixes https://github.com/denoland/deno/issues/20609

Vitepress support! `vitepress dev` and `vitepress build` via BYONM
This commit is contained in:
Divy Srivastava 2024-03-09 09:07:29 +05:30 committed by GitHub
parent 26cee4eb0d
commit 0bed4d3e51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 27 additions and 2 deletions

1
Cargo.lock generated
View file

@ -1425,6 +1425,7 @@ dependencies = [
"deno_io", "deno_io",
"filetime", "filetime",
"fs3", "fs3",
"junction",
"libc", "libc",
"log", "log",
"nix 0.26.2", "nix 0.26.2",

View file

@ -194,6 +194,7 @@ nix = "=0.26.2"
# windows deps # windows deps
fwdansi = "=1.1.0" fwdansi = "=1.1.0"
junction = "=0.2.0"
winapi = "=0.3.9" winapi = "=0.3.9"
windows-sys = { version = "0.48.0", features = ["Win32_Media"] } windows-sys = { version = "0.48.0", features = ["Win32_Media"] }
winres = "=0.1.12" winres = "=0.1.12"

View file

@ -154,7 +154,7 @@ zstd.workspace = true
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
fwdansi.workspace = true fwdansi.workspace = true
junction = "=0.2.0" junction.workspace = true
winapi = { workspace = true, features = ["knownfolders", "mswsock", "objbase", "shlobj", "tlhelp32", "winbase", "winerror", "winsock2"] } winapi = { workspace = true, features = ["knownfolders", "mswsock", "objbase", "shlobj", "tlhelp32", "winbase", "winerror", "winsock2"] }
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]

View file

@ -35,3 +35,4 @@ nix.workspace = true
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
winapi = { workspace = true, features = ["winbase"] } winapi = { workspace = true, features = ["winbase"] }
junction.workspace = true

View file

@ -64,6 +64,8 @@ pub enum FsFileType {
File, File,
#[serde(rename = "dir")] #[serde(rename = "dir")]
Directory, Directory,
#[serde(rename = "junction")]
Junction,
} }
#[derive(Serialize)] #[derive(Serialize)]

View file

@ -810,6 +810,9 @@ fn symlink(
FsFileType::Directory => { FsFileType::Directory => {
std::os::windows::fs::symlink_dir(oldpath, newpath)?; std::os::windows::fs::symlink_dir(oldpath, newpath)?;
} }
FsFileType::Junction => {
junction::create(oldpath, newpath)?;
}
}; };
Ok(()) Ok(())

View file

@ -7,7 +7,7 @@ import { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
import { pathFromURL } from "ext:deno_web/00_infra.js"; import { pathFromURL } from "ext:deno_web/00_infra.js";
import { promisify } from "ext:deno_node/internal/util.mjs"; import { promisify } from "ext:deno_node/internal/util.mjs";
type SymlinkType = "file" | "dir"; type SymlinkType = "file" | "dir" | "junction";
export function symlink( export function symlink(
target: string | URL, target: string | URL,

View file

@ -105,3 +105,20 @@ Deno.test({
} }
}, },
}); });
Deno.test({
name: "SYNC: symlink junction",
fn() {
const dir: string = Deno.makeTempDirSync();
const linkedDir: string = dir + "-junction";
try {
symlinkSync(dir, linkedDir, "junction");
const stat = Deno.lstatSync(linkedDir);
assert(stat.isSymlink);
} finally {
Deno.removeSync(dir);
Deno.removeSync(linkedDir);
}
},
});