import { executeCommand } from './executeWinCommand' ; /**
 * Creates a new variable in the user's environment
 */ const setEnvironment = async ( variable , value ) => { const command = `setx ${ variable } "${ value }"` ; await executeCommand ( command ) ; process . env [ variable ] = value ; } ; param { string } variable param { string } value returns { Promise < void > } const updateEnvironment = async ( variable , value ) => { const envVariable = process . env [ variable ] || '' ; if ( variable === 'PATH' && envVariable . includes ( `${ value };` ) ) { return ; } const command = `for /f "skip=2 tokens=3*" %a in ('reg query HKCU\\Environment /v ${ variable }') do @if [%b]==[] ( @setx ${ variable } "${ value };%~a" ) else ( @setx ${ variable } "${ value };%~a %~b" )
  ` ; await executeCommand ( command ) ; process . env [ variable ] = `${ process . env [ variable ] }${ value };` ; } ; export { setEnvironment , updateEnvironment } ;