work around if NGROK_SERVERHOST isn't in ../.env
This commit is contained in:
parent
9cdc73d5ba
commit
d4329ae706
11
ngrok.js
11
ngrok.js
|
@ -47,12 +47,21 @@ fs.readFile(dotenvFile, "utf8", (err, data) => {
|
|||
const url = await ngrok.connect({ authtoken, proto, addr });
|
||||
|
||||
// Rebuild lines with the new url
|
||||
let found = false;
|
||||
lines = lines.map((element) => {
|
||||
const [name] = element.split("=");
|
||||
if (name === "NGROK_SERVERHOST") return `${name}=${url}`;
|
||||
if (name === "NGROK_SERVERHOST") {
|
||||
found = true;
|
||||
return `${name}=${url}`;
|
||||
}
|
||||
return element;
|
||||
});
|
||||
|
||||
// Is this variable already in the .env, if not add it.
|
||||
if (!found) {
|
||||
lines.unshift(`NGROK_SERVERHOST=${url}`)
|
||||
}
|
||||
|
||||
// convert back to string format
|
||||
let writeData = "";
|
||||
lines.forEach((element) => {
|
||||
|
|
Loading…
Reference in New Issue