refactor(fs): fix uncaught errors in browsers (#6135)

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
This commit is contained in:
Parsa Yazdani 2024-10-24 16:44:27 +11:00 committed by GitHub
parent e3974eae69
commit c0427a02bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 4 deletions

View File

@ -8,7 +8,8 @@ import { getFileInfoType } from "./_get_file_info_type.ts";
import { toPathString } from "./_to_path_string.ts"; import { toPathString } from "./_to_path_string.ts";
import { isSubdir } from "./_is_subdir.ts"; import { isSubdir } from "./_is_subdir.ts";
const isWindows = Deno.build.os === "windows"; // deno-lint-ignore no-explicit-any
const isWindows = (globalThis as any).Deno?.build.os === "windows";
/** Options for {@linkcode copy} and {@linkcode copySync}. */ /** Options for {@linkcode copy} and {@linkcode copySync}. */
export interface CopyOptions { export interface CopyOptions {

View File

@ -5,7 +5,8 @@ import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
import { getFileInfoType, type PathType } from "./_get_file_info_type.ts"; import { getFileInfoType, type PathType } from "./_get_file_info_type.ts";
import { toPathString } from "./_to_path_string.ts"; import { toPathString } from "./_to_path_string.ts";
const isWindows = Deno.build.os === "windows"; // deno-lint-ignore no-explicit-any
const isWindows = (globalThis as any).Deno?.build.os === "windows";
function resolveSymlinkTarget(target: string | URL, linkName: string | URL) { function resolveSymlinkTarget(target: string | URL, linkName: string | URL) {
if (typeof target !== "string") return target; // URL is always absolute path if (typeof target !== "string") return target; // URL is always absolute path

View File

@ -16,7 +16,9 @@ export const CRLF = "\r\n" as const;
* EOL; // "\n" on POSIX platforms and "\r\n" on Windows * EOL; // "\n" on POSIX platforms and "\r\n" on Windows
* ``` * ```
*/ */
export const EOL: "\n" | "\r\n" = Deno?.build.os === "windows" ? CRLF : LF; export const EOL: "\n" | "\r\n" =
// deno-lint-ignore no-explicit-any
(globalThis as any).Deno?.build.os === "windows" ? CRLF : LF;
const regDetect = /(?:\r?\n)/g; const regDetect = /(?:\r?\n)/g;

View File

@ -15,7 +15,8 @@ import {
export type { GlobOptions, WalkEntry }; export type { GlobOptions, WalkEntry };
const isWindows = Deno.build.os === "windows"; // deno-lint-ignore no-explicit-any
const isWindows = (globalThis as any).Deno?.build.os === "windows";
/** Options for {@linkcode expandGlob} and {@linkcode expandGlobSync}. */ /** Options for {@linkcode expandGlob} and {@linkcode expandGlobSync}. */
export interface ExpandGlobOptions extends Omit<GlobOptions, "os"> { export interface ExpandGlobOptions extends Omit<GlobOptions, "os"> {