Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 function findCygwin(): Promise {
const registryPath64 = enumerateValues(
HKEY.HKEY_LOCAL_MACHINE,
'SOFTWARE\\Cygwin\\setup'
)
const registryPath32 = enumerateValues(
HKEY.HKEY_LOCAL_MACHINE,
'SOFTWARE\\WOW6432Node\\Cygwin\\setup'
)
if (registryPath64 == null || registryPath32 == 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')
async function findApplication(editor: ExternalEditor): Promise {
const registryKeys = getRegistryKeys(editor)
let keys: ReadonlyArray = []
for (const { key, subKey } of registryKeys) {
keys = enumerateValues(key, subKey)
if (keys.length > 0) {
break
}
}
if (keys.length === 0) {
return null
}
const {
displayName,
publisher,
installLocation,
} = extractApplicationInformation(editor, keys)
if (!isExpectedInstallation(editor, displayName, publisher)) {
return enumerateKeys(key, subkey).map(k =>
enumerateValues(key, subkey + '\\' + k),
)
async function findGitBash(): 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 path
} else {
log.debug(
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(
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(