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


TypeScript out.Packager類代碼示例

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


在下文中一共展示了Packager類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 || packagerOptions.platformPackagerFactory != null) {
    return
  }

  for (let platform of packagerOptions.platform) {
    if (platform === Platform.OSX) {
      await checkOsXResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.OSX))
    }
    else if (platform === Platform.LINUX) {
      await checkLinuxResult(projectDir, packager, packagerOptions)
    }
    else if (platform === Platform.WINDOWS) {
      await checkWindowsResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.WINDOWS))
    }
  }
}
開發者ID:GabeIsman,項目名稱: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

示例4: 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(event.file).isAbsolute()
    let list = artifacts.get(event.platform)
    if (list == null) {
      list = []
      artifacts.set(event.platform, list)
    }
    list.push(event)
  })

  const platformToTarget = await packager.build()

  if (packagerOptions.platformPackagerFactory != null || packagerOptions.effectiveOptionComputed != null) {
    return
  }

  c: for (let [platform, archToType] of packagerOptions.targets) {
    for (let [arch, targets] of archToType) {
      if (targets.length === 1 && targets[0] === DIR_TARGET) {
        continue c
      }

      const nameToTarget = platformToTarget.get(platform)
      if (platform === Platform.MAC) {
        await checkOsXResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.MAC))
      }
      else if (platform === Platform.LINUX) {
        await checkLinuxResult(projectDir, packager, checkOptions, artifacts.get(Platform.LINUX), arch, nameToTarget)
      }
      else if (platform === Platform.WINDOWS) {
        await checkWindowsResult(packager, checkOptions, artifacts.get(Platform.WINDOWS), arch, nameToTarget)
      }
    }
  }
}
開發者ID:SimplyAhmazing,項目名稱:electron-builder,代碼行數:39,代碼來源:packTester.ts


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