@paroicms/internal-server-lib
Version: 
Common utilitaries for the paroicms server.
19 lines • 480 B
JavaScript
import { mkdir, stat } from "node:fs/promises";
export async function pathExists(path) {
    return !!(await fileStatsOrUndef(path));
}
/**
 * @returns undefined if the file does not exist or can't be accessed
 */
export async function fileStatsOrUndef(path) {
    try {
        return await stat(path);
    }
    catch { }
}
export async function ensureDirectory(path) {
    if (!(await pathExists(path))) {
        await mkdir(path);
    }
}
//# sourceMappingURL=fs-utils.js.map