index.js 298 B

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