forked from eea/volto-accordion-block
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
41 lines (38 loc) · 1.09 KB
/
bootstrap
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
32
33
34
35
36
37
38
39
40
41
const path = require('path');
const fs = require('fs');
const ejs = require('ejs');
const currentDir = path.basename(process.cwd());
const bootstrap = function (ofile) {
fs.readFile(ofile, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
const result = ejs.render(data, {
addonName: `@eeacms/${currentDir}`,
name: currentDir
});
const output = ofile.replace('.tpl', '');
fs.writeFile(output, result, 'utf8', function (err) {
if (err) {
return console.log(err);
}
});
if (ofile.includes('.tpl')) {
fs.unlink(ofile, (err) => {
if (err) {
return console.error(err);
}
});
}
});
}
fs.readdir(".", { withFileTypes: true }, (err, dirents) => {
const files = dirents
.filter(dirent => dirent.isFile())
.map(dirent => dirent.name);
files.forEach(function (file) {
if (file != 'bootstrap') {
bootstrap(file);
}
});
});