当前位置: 首页>>代码示例>>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;未经允许,请勿转载。