import { readdir } from 'fs/promises' /** * getting files * * @author Björn Hase * @license hhttps://www.gnu.org/licenses/gpl-3.0.en.html GPL-3 * @link https://gitea.node001.net/HerrHase/tellme-bot.git * */ class File { /** * * @param {string} path * */ constructor(path) { this.path = path } /** * getting alle files from * * @param {string} path * @return {object} * */ async get() { const result = { files: [], errors: false } try { const files = await readdir(this.path, { withFileTypes: true }) // run through all files, add options for (const file of files) { result['files'].push({ name: file.name, isDirectory: file.isDirectory() }) } } catch (error) { result['errors'] = error } return result } } export default File