Split commands into subdirectories
* Move command files into directories * Edit relative paths * Update gitignore * Finish support for commands in subdir * Split up getCommandFiles into own function * Add support for subdirs on help command
This commit is contained in:
parent
8993eeaf7a
commit
e7cdd425d1
21 changed files with 55 additions and 35 deletions
16
util/getCommandFiles.js
Normal file
16
util/getCommandFiles.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
const fs = require('fs')
|
||||
|
||||
module.exports = function (commandPath) {
|
||||
let subdir = fs.readdirSync(commandPath)
|
||||
let commandFiles = [];
|
||||
subdir.forEach(item => {
|
||||
if(fs.statSync(commandPath+item).isDirectory()){
|
||||
let subdirFiles = fs.readdirSync(commandPath+item).filter(file => file.endsWith('.js'))
|
||||
subdirFiles.forEach(file => {
|
||||
commandFiles.push(commandPath+item+"/"+file)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return commandFiles
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue