Skip to content

Commit

Permalink
Try ga env var
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanebouget committed Mar 5, 2024
1 parent b43fab5 commit 50bdc36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"build-visu": "cd ../visualization-component && yarn build:webcomponents",
"build": "npm run electron:serve-tsc && ng build --base-href ./",
"build:dev": "npm run build -- -c dev",
"build:prod": "node set-env.js && npm run build -- -c production && npm run removeMocks",
"build:prod": "node ./scripts/set-env.js && npm run build -- -c production && npm run removeMocks",
"web:build": "npm run build -- -c web-production",
"electron": "electron",
"electron:serve-tsc": "tsc -p tsconfig.serve.json",
Expand Down
15 changes: 8 additions & 7 deletions scripts/set-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const fs = require("fs");
const envFilePath = "./src/environments/environment.prod.ts";
let envFileContent = fs.readFileSync(envFilePath, "utf8");
const trackerId = process.env.TRACKER_ID;
if (!envFileContent.includes("TRACKER_ID")) {
envFileContent = envFileContent.replace(
/}\s*$/,
` TRACKER_ID: "${trackerId}",\n}`
);
}
fs.writeFileSync(envFilePath, envFileContent);

// insert trackerId to the env file
let index = envFileContent.indexOf("{");
let res =
envFileContent.slice(0, index + 1) +
` TRACKER_ID: "${trackerId}",` +
envFileContent.slice(index + 1);
fs.writeFileSync(envFilePath, res);

0 comments on commit 50bdc36

Please sign in to comment.