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