Get files from top directory + rename file

* Generalise variable names

* Change require stuff to the new thing
This commit is contained in:
SileNce5k 2021-07-22 09:14:06 +02:00
parent 32dbcd062e
commit 047ba95311
No known key found for this signature in database
GPG key ID: C507260E7F2583AD
4 changed files with 26 additions and 20 deletions

22
util/getSubdirFiles.js Normal file
View file

@ -0,0 +1,22 @@
const fs = require('fs')
module.exports = function (path) {
let subdir = fs.readdirSync(path)
let commandFiles = [];
subdir.forEach(item => {
if(fs.statSync(path+item).isDirectory()){
let subdirFiles = fs.readdirSync(path+item)
subdirFiles.forEach(file => {
if(file.endsWith('.js')){
commandFiles.push(path+item+"/"+file)
}
});
}else if(item.endsWith('.js')){
commandFiles.push(path+item)
}
});
return commandFiles
}