diff options
author | Behnam Mohammadi <itten@live.com> | 2020-11-10 08:08:46 +0330 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 15:38:46 +1100 |
commit | 4cc919a742cc39122b6308d53df86b370f99b911 (patch) | |
tree | 51b781acb1cbcadeefa03094d1da47cdd6ca4eff /std/fs | |
parent | 94b68f90697954292f4355cf91e7f75868d8d664 (diff) |
refactor(std/fs): remove unnecessary if else block (#8321)
Diffstat (limited to 'std/fs')
-rw-r--r-- | std/fs/ensure_symlink.ts | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/std/fs/ensure_symlink.ts b/std/fs/ensure_symlink.ts index 03a8db930..7c68d05e2 100644 --- a/std/fs/ensure_symlink.ts +++ b/std/fs/ensure_symlink.ts @@ -4,6 +4,8 @@ import { ensureDir, ensureDirSync } from "./ensure_dir.ts"; import { exists, existsSync } from "./exists.ts"; import { getFileInfoType } from "./_util.ts"; +const isWindows = Deno.build.os == "windows"; + /** * Ensures that the link exists. * 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)); - if (Deno.build.os === "windows") { - await Deno.symlink(src, dest, { + const options: Deno.SymlinkOptions | undefined = isWindows + ? { type: srcFilePathType === "dir" ? "dir" : "file", - }); - } else { - await Deno.symlink(src, dest); - } + } + : undefined; + + await Deno.symlink(src, dest, options); } /** @@ -60,11 +62,12 @@ export function ensureSymlinkSync(src: string, dest: string): void { } ensureDirSync(path.dirname(dest)); - if (Deno.build.os === "windows") { - Deno.symlinkSync(src, dest, { + + const options: Deno.SymlinkOptions | undefined = isWindows + ? { type: srcFilePathType === "dir" ? "dir" : "file", - }); - } else { - Deno.symlinkSync(src, dest); - } + } + : undefined; + + Deno.symlinkSync(src, dest, options); } |