當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript registry-js.enumerateValues函數代碼示例

本文整理匯總了TypeScript中registry-js.enumerateValues函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript enumerateValues函數的具體用法?TypeScript enumerateValues怎麽用?TypeScript enumerateValues使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了enumerateValues函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: findGitBash

async function findGitBash(): Promise<string | null> {
  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(
        `[Git Bash] registry entry found but does not exist at '${path}'`
      )
    }
  }

  return null
}
開發者ID:ghmoore,項目名稱:desktop,代碼行數:25,代碼來源:win32.ts

示例2: findPowerShellCore

async function findPowerShellCore(): Promise<string | null> {
  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
}
開發者ID:ghmoore,項目名稱:desktop,代碼行數:25,代碼來源:win32.ts

示例3: _getAdvinstPathFromReg

function _getAdvinstPathFromReg(): string {

  // Advinst registry constants
  let advinstComPath: string = null;
  // Search the Advanced Installer root path in in both redirected and non-redirected hives.
  const wowRegs = enumerateValues(HKEY.HKEY_LOCAL_MACHINE, advinstWowRegKeyPath).filter(function (reg) { return reg.name === advinstPathRegValue });
  if (wowRegs.length > 0) {
    advinstComPath = path.join(wowRegs[0].data.toString(), advinstToolSubPath, advinstToolCmdLineUtility)
  }
  // Search the Advanced Installer root path in in both redirected and non-redirected hives.
  const regs = enumerateValues(HKEY.HKEY_LOCAL_MACHINE, advinstRegKeyPath).filter(function (reg) { return reg.name === advinstPathRegValue });
  if (regs.length > 0) {
    advinstComPath = path.join(regs[0].data.toString(), advinstToolSubPath, advinstToolCmdLineUtility)
  }

  if (taskLib.exist(advinstComPath)) {
    return advinstComPath;
  }

  return null;
}
開發者ID:Caphyon,項目名稱:advinst-vsts-task,代碼行數:21,代碼來源:AdvinstTool.ts

示例4: findCygwin

async function findCygwin(): Promise<string | null> {
  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')

    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
}
開發者ID:ghmoore,項目名稱:desktop,代碼行數:39,代碼來源:win32.ts

示例5: findHyper

async function findHyper(): Promise<string | null> {
  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

    const path = commandPieces
      ? commandPieces[2]
      : localAppData != null
      ? localAppData.concat('\\hyper\\Hyper.exe')
      : null // fall back to the launcher in install root

    if (path == null) {
      log.debug(
        `[Hyper] LOCALAPPDATA environment variable is unset, aborting fallback behavior`
      )
    } else if (await pathExists(path)) {
      return path
    } else {
      log.debug(`[Hyper] registry entry found but does not exist at '${path}'`)
    }
  }

  return null
}
開發者ID:ghmoore,項目名稱:desktop,代碼行數:38,代碼來源:win32.ts

示例6: findPowerShell

async function findPowerShell(): Promise<string | null> {
  const powerShell = enumerateValues(
    HKEY.HKEY_LOCAL_MACHINE,
    'Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\PowerShell.exe'
  )

  if (powerShell.length === 0) {
    return null
  }

  const first = powerShell[0]

  // NOTE:
  // on Windows 7 these are both REG_SZ, which technically isn't supposed
  // to contain unexpanded references to environment variables. But given
  // it's also %SystemRoot% and we do the expanding here I think this is
  // a fine workaround to do to support the maximum number of setups.

  if (
    first.type === RegistryValueType.REG_EXPAND_SZ ||
    first.type === RegistryValueType.REG_SZ
  ) {
    const path = first.data.replace(
      /^%SystemRoot%/i,
      process.env.SystemRoot || 'C:\\Windows'
    )

    if (await pathExists(path)) {
      return path
    } else {
      log.debug(
        `[PowerShell] registry entry found but does not exist at '${path}'`
      )
    }
  }

  return null
}
開發者ID:ghmoore,項目名稱:desktop,代碼行數:38,代碼來源:win32.ts

示例7: findApplication

async function findApplication(editor: ExternalEditor): Promise<string | null> {
  const registryKeys = getRegistryKeys(editor)

  let keys: ReadonlyArray<RegistryValue> = []
  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)) {
    log.debug(
      `Registry entry for ${editor} did not match expected publisher settings`
    )
    return null
  }

  const path = getExecutableShim(editor, installLocation)
  const exists = await pathExists(path)
  if (!exists) {
    log.debug(`Command line interface for ${editor} not found at '${path}'`)
    return null
  }

  return path
}
開發者ID:Ahskys,項目名稱:desktop,代碼行數:37,代碼來源:win32.ts

示例8: getAvailableShells

export async function getAvailableShells(): Promise<
  ReadonlyArray<IFoundShell<Shell>>
> {
  const shells = [
    {
      shell: Shell.Cmd,
      path: process.env.comspec || 'C:\\Windows\\System32\\cmd.exe',
    },
  ]

  const powerShell = enumerateValues(
    HKEY.HKEY_LOCAL_MACHINE,
    'Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\PowerShell.exe'
  )
  if (powerShell.length > 0) {
    const first = powerShell[0]

    // NOTE:
    // on Windows 7 these are both REG_SZ, which technically isn't supposed
    // to contain unexpanded references to environment variables. But given
    // it's also %SystemRoot% and we do the expanding here I think this is
    // a fine workaround to do to support the maximum number of setups.

    if (
      first.type === RegistryValueType.REG_EXPAND_SZ ||
      first.type === RegistryValueType.REG_SZ
    ) {
      const path = first.data.replace(
        /^%SystemRoot%/i,
        process.env.SystemRoot || 'C:\\Windows'
      )
      shells.push({
        shell: Shell.PowerShell,
        path,
      })
    }
  }

  const hyper = enumerateValues(
    HKEY.HKEY_CURRENT_USER,
    'Software\\Classes\\Directory\\Background\\shell\\Hyper\\command'
  )
  if (hyper.length > 0) {
    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 path = commandPieces
        ? commandPieces[2]
        : process.env.LocalAppData.concat('\\hyper\\Hyper.exe') // fall back to the launcher in install root
      shells.push({
        shell: Shell.Hyper,
        path: path,
      })
    }
  }

  const gitBash = enumerateValues(
    HKEY.HKEY_LOCAL_MACHINE,
    'SOFTWARE\\GitForWindows'
  )

  if (gitBash.length > 0) {
    const installPathEntry = gitBash.find(e => e.name === 'InstallPath')
    if (
      installPathEntry &&
      installPathEntry.type === RegistryValueType.REG_SZ
    ) {
      shells.push({
        shell: Shell.GitBash,
        path: Path.join(installPathEntry.data, 'git-bash.exe'),
      })
    }
  }

  return shells
}
開發者ID:whyamei,項目名稱:desktop,代碼行數:80,代碼來源:win32.ts


注:本文中的registry-js.enumerateValues函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。