mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 00:21:05 -05:00
refactor(std/fs): remove unnecessary if else block (#8321)
This commit is contained in:
parent
94b68f9069
commit
4cc919a742
1 changed files with 15 additions and 12 deletions
|
@ -4,6 +4,8 @@ import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
|
||||||
import { exists, existsSync } from "./exists.ts";
|
import { exists, existsSync } from "./exists.ts";
|
||||||
import { getFileInfoType } from "./_util.ts";
|
import { getFileInfoType } from "./_util.ts";
|
||||||
|
|
||||||
|
const isWindows = Deno.build.os == "windows";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the link exists.
|
* Ensures that the link exists.
|
||||||
* If the directory structure does not exist, it is created.
|
* If the directory structure does not exist, it is created.
|
||||||
|
@ -28,13 +30,13 @@ export async function ensureSymlink(src: string, dest: string): Promise<void> {
|
||||||
|
|
||||||
await ensureDir(path.dirname(dest));
|
await ensureDir(path.dirname(dest));
|
||||||
|
|
||||||
if (Deno.build.os === "windows") {
|
const options: Deno.SymlinkOptions | undefined = isWindows
|
||||||
await Deno.symlink(src, dest, {
|
? {
|
||||||
type: srcFilePathType === "dir" ? "dir" : "file",
|
type: srcFilePathType === "dir" ? "dir" : "file",
|
||||||
});
|
}
|
||||||
} else {
|
: undefined;
|
||||||
await Deno.symlink(src, dest);
|
|
||||||
}
|
await Deno.symlink(src, dest, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,11 +62,12 @@ export function ensureSymlinkSync(src: string, dest: string): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureDirSync(path.dirname(dest));
|
ensureDirSync(path.dirname(dest));
|
||||||
if (Deno.build.os === "windows") {
|
|
||||||
Deno.symlinkSync(src, dest, {
|
const options: Deno.SymlinkOptions | undefined = isWindows
|
||||||
|
? {
|
||||||
type: srcFilePathType === "dir" ? "dir" : "file",
|
type: srcFilePathType === "dir" ? "dir" : "file",
|
||||||
});
|
}
|
||||||
} else {
|
: undefined;
|
||||||
Deno.symlinkSync(src, dest);
|
|
||||||
}
|
Deno.symlinkSync(src, dest, options);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue