UNPKG

@dgac/nmb2b-client

Version:

EUROCONTROL Network Manager B2B SOAP client

27 lines (25 loc) 804 B
import { createDebugLogger } from "./debug.mjs"; import * as fs from "node:fs/promises"; //#region src/utils/fs.ts const debug = createDebugLogger("dir-exists"); async function dirExists(path, { readable, writable } = { readable: true, writable: false }) { debug(`Testing if directory ${path} is readable ${writable ? "and writable " : ""}...`); try { if (!(await fs.stat(path)).isDirectory()) return false; await fs.access(path, (writable ? fs.constants.W_OK : 0) | (readable ? fs.constants.R_OK : 0)); debug(`Directory ${path} is accessible`); return true; } catch { return false; } } async function createDir(path) { debug("Creating directory %s ...", path); await fs.mkdir(path, { recursive: true }); } //#endregion export { createDir, dirExists }; //# sourceMappingURL=fs.mjs.map