-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
set-portable.js
34 lines (25 loc) · 1022 Bytes
/
set-portable.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
/**
* set-portable
*
* helper script to set Media Hoarder to portable/non-portable before the build task (we currently do this because nodejs/javascript don't support macros)
*/
const fs = require("fs");
const minimist = require("minimist");
const { exit } = require("process");
const logger = require("./src/helpers/logger");
logger.setLevel(0);
const cmdArguments = minimist(process.argv.slice(2));
if (!cmdArguments.portable) {
logger.error("set-portable ERROR: Command Line Parameter --portable=[true,false] missing!");
exit(1);
}
const isPORTABLE = cmdArguments.portable === "true";
let content = fs.readFileSync("./src/helpers/helpers.js", "utf8");
if (isPORTABLE) {
content = content.replace(/const isPORTABLE = false/, "const isPORTABLE = true");
logger.log("Media Hoarder set to PORTABLE");
} else {
content = content.replace(/const isPORTABLE = true/, "const isPORTABLE = false");
logger.log("Media Hoarder set to non-PORTABLE");
}
fs.writeFileSync("./src/helpers/helpers.js", content);