Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const publisher = getKeyOrEmpty(keys, 'Publisher')
const installLocation = getKeyOrEmpty(keys, 'InstallLocation')
return { displayName, publisher, installLocation }
}
if (editor === ExternalEditor.Webstorm) {
let displayName = ''
let publisher = ''
let installLocation = ''
for (const item of keys) {
// NOTE:
// Webstorm adds the current release number to the end of the Display Name, below checks for "WebStorm"
if (
item.name === 'DisplayName' &&
item.type === RegistryValueType.REG_SZ &&
item.data.startsWith('WebStorm ')
) {
displayName = 'WebStorm'
} else if (
item.name === 'Publisher' &&
item.type === RegistryValueType.REG_SZ
) {
publisher = item.data
} else if (
item.name === 'InstallLocation' &&
item.type === RegistryValueType.REG_SZ
) {
installLocation = item.data
}
}
// NOTE:
// Webstorm adds the current release number to the end of the Display Name, below checks for "WebStorm"
if (
item.name === 'DisplayName' &&
item.type === RegistryValueType.REG_SZ &&
item.data.startsWith('WebStorm ')
) {
displayName = 'WebStorm'
} else if (
item.name === 'Publisher' &&
item.type === RegistryValueType.REG_SZ
) {
publisher = item.data
} else if (
item.name === 'InstallLocation' &&
item.type === RegistryValueType.REG_SZ
) {
installLocation = item.data
}
}
return { displayName, publisher, installLocation }
}
return assertNever(editor, `Unknown external editor: ${editor}`)
}
(v): v is RegistryStringEntry =>
v && v.type === RegistryValueType.REG_SZ && v.name === 'DisplayName',
)
return taPathRegistryLocations.flatMap(([hkey, key, name]) => {
const values = enumerateValues(hkey, key);
const installPathEntry = values.find(x => x.name === name);
if (
installPathEntry &&
installPathEntry.type === RegistryValueType.REG_SZ
) {
return [installPathEntry.data];
}
return [];
});
}
async function findGitForWindowsInstall(): Promise {
const registryPath = enumerateValues(
HKEY.HKEY_LOCAL_MACHINE,
'SOFTWARE\\GitForWindows'
)
if (registryPath.length === 0) {
return null
}
const installPathEntry = registryPath.find(e => e.name === 'InstallPath')
if (installPathEntry && installPathEntry.type === RegistryValueType.REG_SZ) {
const path = Path.join(installPathEntry.data, 'git-bash.exe')
if (await pathExists(path)) {
return installPathEntry.data
} else {
log.debug(
`[hasGitForWindowsInstall] registry entry found but git-bash.exe does not exist at '${path}'`
)
}
}
return null
}
return null
}
const installPathEntry64 = registryPath64.find(e => e.name === 'rootdir')
const installPathEntry32 = registryPath32.find(e => e.name === 'rootdir')
if (
installPathEntry64 &&
installPathEntry64.type === RegistryValueType.REG_SZ
) {
const path = Path.join(installPathEntry64.data, 'bin\\mintty.exe')
if (await pathExists(path)) {
return path
} else if (
installPathEntry32 &&
installPathEntry32.type === RegistryValueType.REG_SZ
) {
const path = Path.join(installPathEntry32.data, 'bin\\mintty.exe')
if (await pathExists(path)) {
return path
}
} else {
log.debug(`[Cygwin] registry entry found but does not exist at '${path}'`)
}
}
return null
}
async function findPowerShellCore(): Promise {
const powerShellCore = enumerateValues(
HKEY.HKEY_LOCAL_MACHINE,
'Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\pwsh.exe'
)
if (powerShellCore.length === 0) {
return null
}
const first = powerShellCore[0]
if (first.type === RegistryValueType.REG_SZ) {
const path = first.data
if (await pathExists(path)) {
return path
} else {
log.debug(
`[PowerShellCore] registry entry found but does not exist at '${path}'`
)
}
}
return null
}