Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getRegistryKeys(
editor: ExternalEditor
): ReadonlyArray<{ key: HKEY; subKey: string }> {
switch (editor) {
case ExternalEditor.Atom:
return [
{
key: HKEY.HKEY_CURRENT_USER,
subKey:
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\atom',
},
]
case ExternalEditor.AtomBeta:
return [
{
key: HKEY.HKEY_CURRENT_USER,
subKey:
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\atom-beta',
},
]
case ExternalEditor.AtomNightly:
return [
{
key: HKEY.HKEY_CURRENT_USER,
subKey:
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\atom-nightly',
},
]
case ExternalEditor.VisualStudioCode:
return [
// 64-bit version of VSCode (user) - provided by default in 64-bit Windows
{
key: HKEY.HKEY_LOCAL_MACHINE,
subKey:
'SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1',
},
]
case ExternalEditor.VisualStudioCodeInsiders:
return [
// 64-bit version of VSCode (user) - provided by default in 64-bit Windows
{
key: HKEY.HKEY_CURRENT_USER,
subKey:
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{217B4C08-948D-4276-BFBB-BEE930AE5A2C}_is1',
},
// 32-bit version of VSCode (user)
{
key: HKEY.HKEY_CURRENT_USER,
subKey:
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{26F4A15E-E392-4887-8C09-7BC55712FD5B}_is1',
},
// 64-bit version of VSCode (system) - was default before user scope installation
{
key: HKEY.HKEY_LOCAL_MACHINE,
subKey:
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1',
},
// 32-bit version of VSCode (system)
{
key: HKEY.HKEY_LOCAL_MACHINE,
subKey:
'SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1',
},
]
async function findHyper(): Promise {
const hyper = enumerateValues(
HKEY.HKEY_CURRENT_USER,
'Software\\Classes\\Directory\\Background\\shell\\Hyper\\command'
)
if (hyper.length === 0) {
return null
}
const first = hyper[0]
if (first.type === RegistryValueType.REG_SZ) {
// Registry key is structured as "{installationPath}\app-x.x.x\Hyper.exe" "%V"
// This regex is designed to get the path to the version-specific Hyper.
// commandPieces = ['"{installationPath}\app-x.x.x\Hyper.exe"', '"', '{installationPath}\app-x.x.x\Hyper.exe', ...]
const commandPieces = first.data.match(/(["'])(.*?)\1/)
const localAppData = process.env.LocalAppData
async readApps() {
const items = [
...this.enumRegeditItems(
HKEY.HKEY_LOCAL_MACHINE,
'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
),
...this.enumRegeditItems(
HKEY.HKEY_LOCAL_MACHINE,
'Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
),
...this.enumRegeditItems(
HKEY.HKEY_CURRENT_USER,
'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
),
]
return Promise.all(
items.map(itemValues => this.getAppInfoFromRegeditItemValues(itemValues)),
)
}