@alauda/doom
Version:
Doctor Doom making docs.
21 lines (20 loc) • 484 B
JavaScript
import fs from 'node:fs/promises';
export async function pathExists(path, type) {
try {
const stats = await fs.stat(path);
if (type === 'file') {
return stats.isFile();
}
if (type === 'directory') {
return stats.isDirectory();
}
return true;
}
catch {
return false;
}
}
export async function readJson(path) {
const raw = await fs.readFile(path, 'utf8');
return JSON.parse(raw);
}