webhook/node_modules/path-exists/index.js

24 lines
347 B
JavaScript
Raw Normal View History

'use strict';
const fs = require('fs');
2022-11-10 11:43:16 +01:00
const {promisify} = require('util');
2022-11-10 11:43:16 +01:00
const pAccess = promisify(fs.access);
2022-11-10 11:43:16 +01:00
module.exports = async path => {
try {
2022-11-10 11:43:16 +01:00
await pAccess(path);
return true;
2022-11-10 11:43:16 +01:00
} catch (_) {
return false;
}
};
module.exports.sync = path => {
try {
fs.accessSync(path);
return true;
} catch (_) {
return false;
}
};