chomens-bot-js/util/file-exists.js
2022-08-14 16:51:45 +07:00

14 lines
246 B
JavaScript

const fs = require('fs/promises')
async function fileExists (filepath) {
try {
await fs.access(filepath)
return true
} catch (error) {
if (error.code !== 'ENOENT') throw error
return false
}
}
module.exports = fileExists