index.js 347 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const fs = require('fs');
  3. const {promisify} = require('util');
  4. const pAccess = promisify(fs.access);
  5. module.exports = async path => {
  6. try {
  7. await pAccess(path);
  8. return true;
  9. } catch (_) {
  10. return false;
  11. }
  12. };
  13. module.exports.sync = path => {
  14. try {
  15. fs.accessSync(path);
  16. return true;
  17. } catch (_) {
  18. return false;
  19. }
  20. };