github-pages-deploy-action/node_modules/path-exists/index.js

24 lines
347 B
JavaScript
Raw Normal View History

2020-01-28 13:07:56 +08:00
'use strict';
const fs = require('fs');
2020-03-31 20:57:48 +08:00
const {promisify} = require('util');
2020-01-28 13:07:56 +08:00
2020-03-31 20:57:48 +08:00
const pAccess = promisify(fs.access);
2020-01-28 13:07:56 +08:00
2020-03-31 20:57:48 +08:00
module.exports = async path => {
2020-01-28 13:07:56 +08:00
try {
2020-03-31 20:57:48 +08:00
await pAccess(path);
2020-01-28 13:07:56 +08:00
return true;
2020-03-31 20:57:48 +08:00
} catch (_) {
return false;
}
};
module.exports.sync = path => {
try {
fs.accessSync(path);
return true;
} catch (_) {
2020-01-28 13:07:56 +08:00
return false;
}
};