Mon 21 Jul 22:43:21 CEST 2025
This commit is contained in:
parent
6dd650a736
commit
2ccf4043ec
32
js/ui/botui/examples/build.js
Normal file
32
js/ui/botui/examples/build.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Run 'node build.js' to list all examples in index.html
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const unslug = require('unslug');
|
||||
|
||||
const base = './';
|
||||
|
||||
// credit: https://stackoverflow.com/a/24594123/1227747
|
||||
function getDirectories (srcpath) {
|
||||
return fs.readdirSync(srcpath)
|
||||
.filter(file => fs.lstatSync(path.join(srcpath, file)).isDirectory() && file != '.git' && file != 'node_modules')
|
||||
}
|
||||
|
||||
var exDirs = getDirectories(base);
|
||||
var refs = '';
|
||||
|
||||
exDirs.forEach(function (dir) {
|
||||
refs += '<a href="' + base + dir + '">' + unslug(dir) + '</a> \n';
|
||||
});
|
||||
|
||||
fs.readFile(base + 'tmpl-index.html', 'utf8', function (err, content) {
|
||||
|
||||
fs.writeFile(base + 'index.html', content.replace('<EXAMPLES-HERE>', refs), (err) => {
|
||||
if(!err) {
|
||||
console.log('Examples listed in index.html');
|
||||
} else {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user