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

TypeScript packager.normalizePlatforms函数代码示例

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

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



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

示例1: packAndCheck

async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions): Promise<void> {
  const packager = new Packager(packagerOptions)

  const artifacts: Map<Platform, Array<ArtifactCreated>> = new Map()
  packager.artifactCreated(event => {
    assertThat(path.isAbsolute(event.file)).true()
    let list = artifacts.get(event.platform)
    if (list == null) {
      list = []
      artifacts.set(event.platform, list)
    }
    list.push(event)
  })

  await packager.build()

  if (!packagerOptions.dist) {
    return
  }

  for (let platform of normalizePlatforms(packagerOptions.platform)) {
    if (platform === "darwin") {
      await checkOsXResult(packager, artifacts.get(Platform.OSX))
    }
    else if (platform === "linux") {
      await checkLinuxResult(projectDir, packager, packagerOptions)
    }
    else if (platform === "win32") {
      await checkWindowsResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.WINDOWS))
    }
  }
}
开发者ID:atietje,项目名称:electron-builder,代码行数:32,代码来源:packTester.ts


示例2: packAndCheck

async function packAndCheck(projectDir: string, platforms: string[], packagerOptions?: PackagerOptions) {
  const packager = new Packager(Object.assign({
    projectDir: projectDir,
    cscLink: CSC_LINK,
    cscKeyPassword: CSC_KEY_PASSWORD,
    dist: true,
    platform: platforms,
  }, packagerOptions))

  const artifacts: Map<Platform, Array<string>> = new Map()
  packager.artifactCreated((file, platform) => {
    let list = artifacts.get(platform)
    if (list == null) {
      list = []
      artifacts.set(platform, list)
    }
    list.push(file)
  })

  await packager.build()

  for (let key of artifacts.keys()) {
    artifacts.set(key, pathSorter(artifacts.get(key)))
  }

  const expandedPlatforms = normalizePlatforms(platforms)
  if (expandedPlatforms.includes("darwin")) {
    await checkOsXResult(packager, artifacts.get(Platform.OSX))
  }
  else if (expandedPlatforms.includes("linux")) {
    const productName = getProductName(packager.metadata)
    const expectedContents = expectedLinuxContents.map(it => {
      if (it === "/opt/TestApp/TestApp") {
        return "/opt/" + productName + "/" + productName
      }
      else if (it === "/usr/share/applications/TestApp.desktop") {
        return `/usr/share/applications/${productName}.desktop`
      }
      else {
        return it.replace(new RegExp("/opt/TestApp/", "g"), `/opt/${productName}/`)
      }
    })
    // let normalizedAppName = getProductName(packager.metadata).toLowerCase().replace(/ /g, '-')
    // expectedContents[expectedContents.indexOf("/usr/share/doc/testapp/")] = "/usr/share/doc/" + normalizedAppName + "/"
    // expectedContents[expectedContents.indexOf("/usr/share/doc/testapp/changelog.Debian.gz")] = "/usr/share/doc/" + normalizedAppName + "/changelog.Debian.gz"

    assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName)).deepEqual(expectedContents)
    if (packagerOptions == null || packagerOptions.arch === null || packagerOptions.arch === "ia32") {
      assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName)).deepEqual(expectedContents)
    }
    // console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb"), null, 2))
    // console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb"), null, 2))
  }
  else if (expandedPlatforms.includes("win32") && (packagerOptions == null || packagerOptions.target == null)) {
    await checkWindowsResult(packagerOptions, artifacts.get(Platform.WINDOWS))
  }
}
开发者ID:TakT,项目名称:electron-builder,代码行数:57,代码来源:packTester.ts


示例3: packAndCheck

async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions): Promise<void> {
  const packager = new Packager(packagerOptions)

  const artifacts: Map<Platform, Array<ArtifactCreated>> = new Map()
  packager.artifactCreated(event => {
    assertThat(path.isAbsolute(event.file)).true()
    let list = artifacts.get(event.platform)
    if (list == null) {
      list = []
      artifacts.set(event.platform, list)
    }
    list.push(event)
  })

  await packager.build()

  if (!packagerOptions.dist) {
    return
  }

  for (let platform of normalizePlatforms(packagerOptions.platform)) {
    if (platform === "darwin") {
      await checkOsXResult(packager, artifacts.get(Platform.OSX))
    }
    else if (platform === "linux") {
      const productName = getProductName(packager.metadata, packager.devMetadata)
      const expectedContents = expectedLinuxContents.map(it => {
        if (it === "/opt/TestApp/TestApp") {
          return "/opt/" + productName + "/" + productName
        }
        else if (it === "/usr/share/applications/TestApp.desktop") {
          return `/usr/share/applications/${productName}.desktop`
        }
        else {
          return it.replace(new RegExp("/opt/TestApp/", "g"), `/opt/${productName}/`)
        }
      })

      // console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName), null, 2))
      // console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2))

      assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName)).deepEqual(expectedContents)
      if (packagerOptions == null || packagerOptions.arch === null || packagerOptions.arch === "ia32") {
        assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName)).deepEqual(expectedContents)
      }
    }
    else if (platform === "win32" && (packagerOptions == null || packagerOptions.target == null)) {
      await checkWindowsResult(packager, packagerOptions, artifacts.get(Platform.WINDOWS))
    }
  }
}
开发者ID:bundyo,项目名称:electron-builder,代码行数:51,代码来源:packTester.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript platformPackager.getArchSuffix函数代码示例发布时间:2022-05-25
下一篇:
TypeScript gitHubPublisher.GitHubPublisher类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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