UNPKG

@inlang/paraglide-js

Version:

[![Inlang-ecosystem compatibility badge](https://cdn.jsdelivr.net/gh/opral/monorepo@main/inlang/assets/md-badges/inlang.svg)](https://inlang.com)

24 lines (23 loc) 527 B
/** * Returns true if the path exists (file or directory), false otherwise. * * @param nodeishFs * @returns */ export async function pathExists(filePath, fs) { try { await fs.stat(filePath); return true; } catch (error) { //@ts-expect-error - error is Error if (error.code === "ENOENT") { return false; } else { throw new Error(`Failed to check if path exists: ${error}`, { cause: error, }); } } }