How to use the accessAsync function from fs-extra
Find comprehensive JavaScript fs-extra.accessAsync code examples handpicked from public code repositorys.
GitHub: gpf0710/poi

93 94 95 96 97 98 99 100 101 102
const downloadAsync = async (url, destDir, filename = path.basename(url), description) => { log(`Downloading ${description} from ${url}`) await fs.ensureDirAsync(destDir) const destPath = path.join(destDir, filename) try { await fs.accessAsync(destPath, fs.R_OK) log(`Use existing ${destPath}`) }catch (e) { const [response, body] = await requestAsync({ url: url,
GitHub: mulesoft-labs/gemini

16 17 18 19 20 21 22 23 24 25
const referencePath = opts.refPath; const currentPath = temp.path({suffix: '.png'}); return capture.image.save(currentPath) .then(() => { return fs.accessAsync(referencePath) .catch( () => Promise.reject(new NoRefImageError(referencePath, currentPath)) ); })
GitHub: dacsang97/huncwot

61 62 63 64 65 66 67 68 69 70
.reduce((a, b) => a || b); } async function exists(pathname) { try { await fs.accessAsync(pathname); return true; } catch (error) { return false; }
184 185 186 187 188 189 190 191 192 193
* Replace exceptions from fs.access with IgnorableError * @param filename * @returns {Promise.<undefined>|*} */ fileAccessable(filename) { return Fse.accessAsync(filename, Fse.constants.R_OK) .then(BbPromise.resolve, (err) => { if (process.env.SLS_DEBUG) { this.log(err.stack);
134 135 136 137 138 139 140 141 142 143
} getSizeFromLocal(src) { // make sure the image exists, then get its size const filepath = path.resolve(this.tplPath, src) return fse.accessAsync(filepath, fse.F_OK).then(() => { this.copyLocalImgToBuild(src) return sizeOf(filepath) }) }
GitHub: opencollective/wiki

9 10 11 12 13 14 15 16 17 18
module.exports = Promise.mapSeries([ /** * SimpleMDE */ () => { return fs.accessAsync('./assets/js/simplemde').then(() => { console.info(colors.white(' └── ') + colors.magenta('SimpleMDE directory already exists. Task aborted.')) return true }).catch(err => { if (err.code === 'ENOENT') {
+ 3 other calls in file
GitHub: jasper-zsh/ngconf

101 102 103 104 105 106 107 108 109 110
Cache.prototype.getAll = function () { return this._cache; }; Cache.prototype.isProfileCached = function (profile) { return fs.accessAsync(path.join(this._options.cachePath, profile), fs.constants.F_OK).then(() => { return Promise.resolve(true); }).catch((err) => { return Promise.resolve(false); })
73 74 75 76 77 78 79 80 81 82
const downloadAsync = async (url, destDir, filename = path.basename(url), description) => { log(`Downloading ${description} from ${url}`); await fs.ensureDirAsync(destDir); const destPath = path.join(destDir, filename); try { await fs.accessAsync(destPath, fs.R_OK); log(`Use existing ${destPath}`); } catch (e) { const [response, body] = await requestAsync({ url,
+ 3 other calls in file
GitHub: purepennons/UDFS

11 12 13 14 15 16 17 18 19 20
module.exports = function deleteMeta(req, res, next) { let fs_id = req.params.fs_id let meta_id = req.params.meta_id let target = path.resolve(path.join(storage_path, fs_id, `${meta_id}_meta`)) fs.accessAsync(target, fs.F_OK) .then( () => { return fs.unlinkAsync(target) }) .then( () => {
GitHub: 07souravkunda/cypress

94 95 96 97 98 99 100 101 102 103
debug('appPath %s', appPath) debug('dest path %s', dest) // make sure this path exists! return fs.accessAsync(appPath) .then(() => { debug('appPath exists %s', appPath) // clear out the existing symlink
GitHub: robbynshaw/wiki

66 67 68 69 70 71 72 73 74 75
ora.text = 'Wiki.js npm dependencies installed successfully.' resolve(true) }) }) }).then(() => { fs.accessAsync(path.join(installDir, 'config.yml')).then(() => { /** * Upgrade mode */ return new Promise((resolve, reject) => {
fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)