mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-12-01 14:45:43 -05:00
20 lines
372 B
JavaScript
20 lines
372 B
JavaScript
const fs = require('fs/promises')
|
|
|
|
/**
|
|
* check if file exists
|
|
* @param {String} filepath the file path
|
|
* @return {boolean} if file exists true else false
|
|
*/
|
|
async function fileExists (filepath) {
|
|
try {
|
|
await fs.access(filepath)
|
|
return true
|
|
} catch (error) {
|
|
if (error.code !== 'ENOENT') throw error
|
|
|
|
return false
|
|
}
|
|
}
|
|
|
|
module.exports = fileExists
|