mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-08 11:04:15 +00:00
Transport OS ENV into environment.prod.ts - Append file
This commit is contained in:
parent
ef38319b5f
commit
7e6f64b16a
24
set-variables-in-env.js
Normal file
24
set-variables-in-env.js
Normal file
@ -0,0 +1,24 @@
|
||||
const yargs = require('yargs');
|
||||
// const tmp = require('tmp');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const argv = yargs.argv;
|
||||
const tempFile = `.temp-var-file.ts`;
|
||||
|
||||
if(argv.set) {
|
||||
const envFile = argv.set;
|
||||
|
||||
console.log(`Backuping up '${envFile}' into '${tempFile}'.`);
|
||||
fs.copyFileSync(envFile, tempFile);
|
||||
const content = fs.readFileSync(envFile, "utf8");
|
||||
const variables = `solarputty_download_url: '${process.env.SOLARPUTTY_DOWNLOAD_URL}',`
|
||||
const replaced = content.replace('//ENV', variables);
|
||||
fs.writeFileSync(envFile, replaced);
|
||||
}
|
||||
|
||||
if(argv.unset) {
|
||||
const envFile = argv.unset;
|
||||
console.log(`Restoring '${tempFile}' into '${envFile}'.`);
|
||||
fs.copyFileSync(tempFile, envFile);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user