当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript builder-util-runtime.parseXml函数代码示例

本文整理汇总了TypeScript中builder-util-runtime.parseXml函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parseXml函数的具体用法?TypeScript parseXml怎么用?TypeScript parseXml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parseXml函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: pathSorter

  packed: async context => {
    const pkgPath = path.join(context.outDir, "Test App ßW-1.1.0.pkg")
    console.log("CALL")
    const fileList = pathSorter(parseFileList(await exec("pkgutil", ["--payload-files", pkgPath]), false))
    expect(fileList).toMatchSnapshot()

    const unpackedDir = path.join(context.outDir, "pkg-unpacked")
    await exec("pkgutil", ["--expand", pkgPath, unpackedDir])

    const info = parseXml(await readFile(path.join(unpackedDir, "Distribution"), "utf8"))
    for (const element of info.getElements("pkg-ref")) {
      element.removeAttribute("installKBytes")
      const bundleVersion = element.elementOrNull("bundle-version")
      if (bundleVersion != null) {
        bundleVersion.element("bundle").removeAttribute("CFBundleVersion")
      }
    }

    // delete info.product.version
    info.element("product").removeAttribute("version")

    expect(info).toMatchSnapshot()

    const scriptDir = path.join(unpackedDir, "org.electron-builder.testApp.pkg", "Scripts")
    await Promise.all([
      assertThat(path.join(scriptDir, "postinstall")).isFile(),
      assertThat(path.join(scriptDir, "preinstall")).isFile(),
    ])
  }
开发者ID:electron-userland,项目名称:electron-builder,代码行数:29,代码来源:macArchiveTest.ts

示例2: exec

  packed: async context => {
    const pkgPath = path.join(context.outDir, "Test App ßW-1.1.0.pkg")
    const unpackedDir = path.join(context.outDir, "pkg-unpacked")
    await exec("pkgutil", ["--expand", pkgPath, unpackedDir])

    const packageInfoFile = path.join(unpackedDir, "org.electron-builder.testApp.pkg", "PackageInfo")
    const info = parseXml(await readFile(packageInfoFile, "utf8"))

    const relocateElement = info.elementOrNull("relocate")
    if (relocateElement) {
      expect(relocateElement.elements).toBeNull()
    }

    const upgradeBundleElement = info.elementOrNull("upgrade-bundle")
    if (upgradeBundleElement) {
      expect(upgradeBundleElement.elements).toBeNull()
    }

    const updateBundleElement = info.elementOrNull("update-bundle")
    if (updateBundleElement) {
      expect(updateBundleElement.elements).toHaveLength(1)
    }

    const strictIdentifierElement = info.elementOrNull("strict-identifier")
    if (strictIdentifierElement) {
      expect(strictIdentifierElement.elements).toBeNull()
    }
  }
开发者ID:electron-userland,项目名称:electron-builder,代码行数:28,代码来源:macArchiveTest.ts

示例3: getLatestVersion

  async getLatestVersion(): Promise<UpdateInfo> {
    const cancellationToken = new CancellationToken()

    const feedXml: string = (await this.httpRequest(newUrlFromBase(`${this.basePath}.atom`, this.baseUrl), {
      accept: "application/xml, application/atom+xml, text/xml, */*",
    }, cancellationToken))!

    const feed = parseXml(feedXml)
    let latestRelease = feed.element("entry", false, `No published versions on GitHub`)
    let version: string | null
    try {
      if (this.updater.allowPrerelease) {
        // noinspection TypeScriptValidateJSTypes
        version = latestRelease.element("link").attribute("href").match(hrefRegExp)!![1]
      }
      else {
        version = await this.getLatestVersionString(cancellationToken)
        for (const element of feed.getElements("entry")) {
          if (element.element("link").attribute("href").match(hrefRegExp)!![1] === version) {
            latestRelease = element
            break
          }
        }

      }
    }
    catch (e) {
      throw newError(`Cannot parse releases feed: ${e.stack || e.message},\nXML:\n${feedXml}`, "ERR_UPDATER_INVALID_RELEASE_FEED")
    }

    if (version == null) {
      throw newError(`No published versions on GitHub`, "ERR_UPDATER_NO_PUBLISHED_VERSIONS")
    }

    const channelFile = getChannelFilename(this.getDefaultChannelName())
    const channelFileUrl = newUrlFromBase(this.getBaseDownloadPath(version, channelFile), this.baseUrl)
    const requestOptions = this.createRequestOptions(channelFileUrl)
    let rawData: string
    try {
      rawData = (await this.executor.request(requestOptions, cancellationToken))!!
    }
    catch (e) {
      if (!this.updater.allowPrerelease && e instanceof HttpError && e.statusCode === 404) {
        throw newError(`Cannot find ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND")
      }
      throw e
    }

    const result = parseUpdateInfo(rawData, channelFile, channelFileUrl)
    if (result.releaseName == null) {
      result.releaseName = latestRelease.elementValueOrEmpty("title")
    }

    if (result.releaseNotes == null) {
      result.releaseNotes = computeReleaseNotes(this.updater.currentVersion, this.updater.fullChangelog, feed, latestRelease)
    }
    return result
  }
开发者ID:electron-userland,项目名称:electron-builder,代码行数:58,代码来源:GitHubProvider.ts


注:本文中的builder-util-runtime.parseXml函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。