chomens-bot-js/util/file-list.js

19 lines
363 B
JavaScript
Raw Normal View History

2022-11-15 21:33:16 -05:00
const fs = require('fs/promises');
2022-08-14 05:51:45 -04:00
2022-11-15 21:33:16 -05:00
/**
* just list the files
* @param {String} filepath file path
* @return {Array} component.
*/
async function list(filepath = '.') {
const files = await fs.readdir(filepath);
2022-08-14 05:51:45 -04:00
2022-11-15 21:33:16 -05:00
const component = [];
2022-08-14 05:51:45 -04:00
files.forEach((filename, index) => {
2022-11-15 21:33:16 -05:00
component.push(filename);
});
return component;
2022-08-14 05:51:45 -04:00
}
2022-11-15 21:33:16 -05:00
module.exports = list;