forked from OpenStickCommunity/WebConfigurator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefsdata.js
38 lines (32 loc) · 1.26 KB
/
makefsdata.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
32
33
34
35
36
37
38
const path = require('path');
const fs = require('fs');
const exec = require('child_process').execFile;
const root = path.dirname(require.main.filename).replace(path.normalize("www"), "");
const rootwww = path.dirname(require.main.filename);
const fsdata_filename = path.normalize("/lib/httpd/fsdata.c");
function correctincludes() {
fs.readFile(root + fsdata_filename, "utf8", function (error, data) {
if (data) {
let result = data.replace("#include \"lwip/apps/fs.h\"\r\n#include \"lwip/def.h\"", '#include "fsdata.h"');
fs.writeFile(root + fsdata_filename, result, "utf8", function (error) {
if (error) {
console.error(error);
}
});
} else {
if (error) {
console.error(error);
}
}
});
}
function makefsdata() {
exec(path.normalize(process.platform !== "darwin" ? `${root}/tools/makefsdata` : `${root}/tools/makefsdata.darwin`), [path.normalize(`${rootwww}/build`), '-defl:1', '-xc:png,ico,json', `-f:`+ path.normalize(`${root}/lib/httpd/fsdata.c`)], function(error, data) {
if (error) {
console.error(error);
} else {
correctincludes();
}
});
}
makefsdata();