import * as path from "../path/mod.ts";import { ensureDir, ensureDirSync } from "./ensure_dir.ts";import { getFileInfoType, toPathString } from "./_util.ts";import { isWindows } from "../_util/os.ts";
export async function ensureSymlink(src: string | URL, dest: string | URL) { const srcStatInfo = await Deno.lstat(src); const srcFilePathType = getFileInfoType(srcStatInfo);
await ensureDir(path.dirname(toPathString(dest)));
const options: Deno.SymlinkOptions | undefined = isWindows ? { type: srcFilePathType === "dir" ? "dir" : "file", } : undefined;
await Deno.symlink(src, dest, options);}
export function ensureSymlinkSync(src: string | URL, dest: string | URL) { const srcStatInfo = Deno.lstatSync(src); const srcFilePathType = getFileInfoType(srcStatInfo);
ensureDirSync(path.dirname(toPathString(dest)));
const options: Deno.SymlinkOptions | undefined = isWindows ? { type: srcFilePathType === "dir" ? "dir" : "file", } : undefined;
Deno.symlinkSync(src, dest, options);}