1
0
Fork 0
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:
Behnam Mohammadi 2020-11-10 08:08:46 +03:30 committed by GitHub
parent 94b68f9069
commit 4cc919a742
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
} }