forked from tum-esi/wade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinstall.js
51 lines (41 loc) · 1.42 KB
/
postinstall.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
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* A simple script that comments out parts of node-dtls-client and the vm2 for node-wot Servient.
* Needed to make sure building wade does not fail.
*/
fs = require("fs");
const PATH_AEAD = "./node_modules/node-dtls-client/build/lib/AEADCrypto.js"
const PATH_SERVIENT = "./node_modules/@node-wot/core/dist/servient.js"
// Commenting out line in node-dtls-client
let lines = [""];
try {
lines = fs.readFileSync(PATH_AEAD).toString().split("\n");
console.log("Read file " + PATH_AEAD + " successfully");
} catch (err) {
console.error(err);
return
}
for(let i=51; i<55; i++){
if(!lines[i].startsWith("// ")) lines[i] = "// " + lines[i];
}
let text = lines.join("\n");
fs.writeFile(PATH_AEAD, text, function (err) {
if (err) return console.log(err)
else console.log("Written to file " + PATH_AEAD + " successfully");
});
// Commenting out lines servient.js (concerning vm2)
try {
lines = fs.readFileSync(PATH_SERVIENT).toString().split("\n");
console.log("Read file " + PATH_SERVIENT + " successfully");
} catch (err) {
console.error(err);
return
}
if(!lines[2].startsWith("// ")) lines[2] = "// " + lines[2];
for(let i=14; i<68; i++){
if(!lines[i].startsWith("// ")) lines[i] = "// " + lines[i];
}
text = lines.join("\n");
fs.writeFile(PATH_SERVIENT, text, function (err) {
if (err) return console.log(err)
else console.log("Written to file " + PATH_SERVIENT + " successfully");
});