UNPKG

298 BJavaScriptView Raw
1import fs, {promises as fsPromises} from 'node:fs';
2
3export async function pathExists(path) {
4 try {
5 await fsPromises.access(path);
6 return true;
7 } catch {
8 return false;
9 }
10}
11
12export function pathExistsSync(path) {
13 try {
14 fs.accessSync(path);
15 return true;
16 } catch {
17 return false;
18 }
19}