-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprebuild.js
More file actions
31 lines (27 loc) · 1.02 KB
/
prebuild.js
File metadata and controls
31 lines (27 loc) · 1.02 KB
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
/* Used to convert the doc files to html pages that can be used in the windows */
const fs = require('fs-extra');
const path = require('path');
const showdown = require('showdown');
var converter = new showdown.Converter();
converter.setOption('openLinksInNewWindow', 'true');
var docFolder = "docs";
var outputFolder = path.join("src", "page", "doctohtml");
fs.readdir(docFolder, function(err, items) {
for(var i=0; i<items.length; i++) {
var file = path.join(docFolder, items[i]);
var outputFile = path.join(outputFolder, items[i].split('.').slice(0, -1).join('.') + ".html");
console.log("Converting: " + file);
fs.readFile(file, 'utf8', (err, data) => {
if(err) {
throw err;
}
try {
fs.writeFileSync(outputFile, converter.makeHtml(data));
console.log("Output: " + outputFile);
} catch (e) {
console.log(e);
//Do nothing I guess?
}
});
}
});