Довёл fix20: firewall-mode, staged state, diagnostics, readiness и build-gate
This commit is contained in:
@@ -1,5 +1,28 @@
|
||||
export async function exists(path: string): Promise<boolean> {
|
||||
return await Bun.file(path).exists();
|
||||
import { stat } from "node:fs/promises";
|
||||
|
||||
async function statSafe(path: string): Promise<import("node:fs").Stats | null> {
|
||||
try {
|
||||
return await stat(path);
|
||||
} catch (error) {
|
||||
if (error && typeof error === "object" && "code" in error && (error as { code?: string }).code === "ENOENT") {
|
||||
return null;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function pathExists(path: string): Promise<boolean> {
|
||||
return (await statSafe(path)) !== null;
|
||||
}
|
||||
|
||||
export async function fileExists(path: string): Promise<boolean> {
|
||||
const st = await statSafe(path);
|
||||
return st?.isFile() ?? false;
|
||||
}
|
||||
|
||||
export async function dirExists(path: string): Promise<boolean> {
|
||||
const st = await statSafe(path);
|
||||
return st?.isDirectory() ?? false;
|
||||
}
|
||||
|
||||
export async function readText(path: string): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user