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