I have these files in folder X: 1.js 2.js, 3.js and this is my code
const commandFiles = fs.readdirSync('./X');
for (const file of commandFiles) {
const files= require(`./X/${file}`);
}
This currently gets the files 1,2,3 and stores it under files
I want to add a subfolder within folder X with more .js files here's an example:
- X=>contains 1.js, 2.js,3.js and folder Y in it
- Y=>contains a.js,b.js
So how would I add these new js files in folder Y to the const
files
?