• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap