Skip to content

Commit

Permalink
Fixed application env when setting system env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
RBFraphael committed Jun 30, 2023
1 parent 1311be6 commit cb140cc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/gui_src/main/helpers/envvars.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@ const { exec } = require("child_process");
const appPath = process.env.PATH.split(";").filter((segment) => segment.trim().length > 0).filter((segment) => segment.indexOf("node_modules") > -1);

export function getVar(variable, callback){
variable = variable.toUpperCase();

exec(`echo %${variable}%`, (err, stdOut, stdErr) => {
if(err == null){
if(callback){
callback(stdOut);
}
}
});
}
};

export function setVar(variable, value, callback){
variable = variable.toUpperCase();

process.env = {
...process.env,
[variable]: value
};

exec(`setx ${variable} "${value}"`, (err, stdOut, stdErr) => {
if(err == null){
if(callback){
Expand Down

0 comments on commit cb140cc

Please sign in to comment.