Get files from top directory + rename file
* Generalise variable names * Change require stuff to the new thing
This commit is contained in:
parent
32dbcd062e
commit
047ba95311
4 changed files with 26 additions and 20 deletions
22
util/getSubdirFiles.js
Normal file
22
util/getSubdirFiles.js
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue