forked from BearTS/Mai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
31 lines (22 loc) · 756 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// runs on npm build command - updates command database for website use;
//
//
const { readdirSync, writeFile } = require('fs');
const files = [];
const paths = readdirSync('./commands').filter(x => x.split('.').length === 1);
for (const path of paths){
const commands = readdirSync('./commands/' + path).filter(x => x.split('.').pop() === 'js');
for (const command of commands){
const file = require('./commands/' + path + '/' + command);
const examples = file.examples;
delete file.examples;
file.examples = examples;
delete file.run;
files.push(file);
};
};
const file = JSON.stringify(files, null, 2);
const path = './assets/json/command-database.json';
writeFile(path, file, (err) => {
console.log({ err })
})