Better debugging
This commit is contained in:
1 parent
ce04a1af1a
commit
21593001ae
7 files changed
+45
-8
No files matched your search
@@ -0,0 +1,33 @@
|
||||
const fs = require('fs');
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
console.error("Invalid usage! usage: npm run manifest-symbols -- SYMBOL1=true [SYMBOL2=false]")
|
||||
exit(-1)
|
||||
}
|
||||
|
||||
function argsToSymbolsObject(arr) {
|
||||
return arr.reduce(function (acc, value) {
|
||||
keyValue = value.split("=")
|
||||
acc[keyValue[0]] = keyValue[1]
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
|
||||
const newSymbols = argsToSymbolsObject(process.argv.slice(2))
|
||||
let currentSymbols = {}
|
||||
|
||||
const appManifestLines = fs.readFileSync("./src/manifest", { encoding: 'utf8', flag: 'r' }).split('\n')
|
||||
const bsConstIndex = appManifestLines.findIndex(line => line.startsWith("bs_const="))
|
||||
if (bsConstIndex !== -1) {
|
||||
let bsConst = appManifestLines[bsConstIndex]
|
||||
bsConst = bsConst.substring("bs_const=".length)
|
||||
currentSymbols = argsToSymbolsObject(bsConst.split(";"))
|
||||
}
|
||||
|
||||
mergedSymbols = {...currentSymbols, ...newSymbols}
|
||||
|
||||
bsConst = "bs_const=" + Object.keys(mergedSymbols).map(key => `${key}=${mergedSymbols[key]}`).join(";")
|
||||
|
||||
appManifestLines[bsConstIndex] = bsConst
|
||||
|
||||
fs.writeFileSync("./src/manifest", appManifestLines.join("\n"))
|
||||
Reference in new issue
Block a user