2017-12-15 18:56:14 +00:00
|
|
|
'use strict';
|
2021-05-08 12:39:21 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
const {promisify} = require('util');
|
2017-12-15 18:56:14 +00:00
|
|
|
|
2021-05-08 12:39:21 +00:00
|
|
|
const pAccess = promisify(fs.access);
|
2017-12-15 18:56:14 +00:00
|
|
|
|
2021-05-08 12:39:21 +00:00
|
|
|
module.exports = async path => {
|
|
|
|
try {
|
|
|
|
await pAccess(path);
|
|
|
|
return true;
|
|
|
|
} catch (_) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-15 18:56:14 +00:00
|
|
|
};
|
|
|
|
|
2021-05-08 12:39:21 +00:00
|
|
|
module.exports.sync = path => {
|
2017-12-15 18:56:14 +00:00
|
|
|
try {
|
2021-05-08 12:39:21 +00:00
|
|
|
fs.accessSync(path);
|
2017-12-15 18:56:14 +00:00
|
|
|
return true;
|
2021-05-08 12:39:21 +00:00
|
|
|
} catch (_) {
|
2017-12-15 18:56:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|