Stop using setx to notify other processes. Doesn't seem to make a difference

I tried keeping some command line sessions, and they weren't aware of changes in PATH neither with this hack or with the existing prod implementation (100% based on setx), so... why bother?
This commit is contained in:
Sergio Padrino 2024-03-05 12:40:22 +01:00
parent 173818da57
commit c661901e5b

View file

@ -1,5 +1,4 @@
import { spawn as spawnInternal } from 'child_process'
import * as Path from 'path'
import {
HKEY,
RegistryValueType,
@ -54,10 +53,6 @@ export async function setPathSegments(
value.type,
paths.join(';')
)
// HACK: We need to notify Windows that the environment has changed. We will
// leverage setx to do this using a dummy environment variable.
await spawnSetX('GITHUB_DESKTOP_ENV_VAR_CHANGE', '1')
} catch (e) {
log.error('Failed setting PATH environment variable', e)
@ -65,19 +60,6 @@ export async function setPathSegments(
}
}
async function spawnSetX(variable: string, value: string) {
let setxPath: string
const systemRoot = process.env['SystemRoot']
if (systemRoot) {
const system32Path = Path.join(systemRoot, 'System32')
setxPath = Path.join(system32Path, 'setx.exe')
} else {
setxPath = 'setx.exe'
}
await spawn(setxPath, [variable, value])
}
/** Spawn a command with arguments and capture its output. */
export function spawn(
command: string,