Merge branch 'dev' into feat/lam-1291/stress-testing
* dev: (85 commits) chore: console.log debug leftovers fix: third level navigation links fix: show subheader on refresh fix: machines/:id routing fix: customer route chore: update wallet nodes feat: shorten long addresses in funding page feat: shorten long addresses refactor: support copied text different from presented text chore: udpate react, downshift and routing refactor: use Wizard component on first route fix: autocomplete component rendering feat: skip2fa option on .env fix: drop contraint before dropping index chore: stop using alias imports fix: re-instate urlResolver chore: server code formatting chore: reformat code chore: adding eslint and prettier config chore: typo ...
This commit is contained in:
commit
e10493abc6
1398 changed files with 60329 additions and 157527 deletions
30
packages/server/tools/set-env-var.js
Normal file
30
packages/server/tools/set-env-var.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
const fs = require('fs')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const setEnvVariable = (key, value, opts) => {
|
||||
const ENV_PATH = !_.isNil(opts?.ENV_PATH)
|
||||
? opts.ENV_PATH
|
||||
: path.resolve(__dirname, '../.env')
|
||||
const ENV_VARIABLES = fs.readFileSync(ENV_PATH, 'utf-8').split(os.EOL)
|
||||
const target = ENV_VARIABLES.indexOf(
|
||||
ENV_VARIABLES.find(line => line.match(new RegExp(`^${key}=`))),
|
||||
)
|
||||
|
||||
if (target < 0) {
|
||||
// The variable doesn't exist, add it
|
||||
ENV_VARIABLES.push(`${key}=${value}`)
|
||||
} else {
|
||||
// .env already has that variable set, or at least has the definition of its key
|
||||
//
|
||||
// This is currently circumventing a possible bug on dotenv
|
||||
// where the variables on this script were showing up as undefined on the first run despite the key existing,
|
||||
// while on a second run they'd appear as empty string, as intended
|
||||
ENV_VARIABLES.splice(target, 1, `${key}=${value}`)
|
||||
}
|
||||
|
||||
fs.writeFileSync(ENV_PATH, ENV_VARIABLES.join(os.EOL))
|
||||
}
|
||||
|
||||
module.exports = setEnvVariable
|
||||
Loading…
Add table
Add a link
Reference in a new issue