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


TypeScript TmpDir.getTempFile方法代码示例

本文整理汇总了TypeScript中builder-util.TmpDir.getTempFile方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TmpDir.getTempFile方法的具体用法?TypeScript TmpDir.getTempFile怎么用?TypeScript TmpDir.getTempFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在builder-util.TmpDir的用法示例。


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

示例1: downloadCertificate

export async function downloadCertificate(urlOrBase64: string, tmpDir: TmpDir, currentDir: string): Promise<string> {
  urlOrBase64 = urlOrBase64.trim()

  let file: string | null = null
  if ((urlOrBase64.length > 3 && urlOrBase64[1] === ":") || urlOrBase64.startsWith("/") || urlOrBase64.startsWith(".")) {
    file = urlOrBase64
  }
  else if (urlOrBase64.startsWith("file://")) {
    file = urlOrBase64.substring("file://".length)
  }
  else if (urlOrBase64.startsWith("~/")) {
    file = path.join(homedir(), urlOrBase64.substring("~/".length))
  }
  else {
    const isUrl = urlOrBase64.startsWith("https://")
    if (isUrl || urlOrBase64.length > 2048 || urlOrBase64.endsWith("=")) {
      const tempFile = await tmpDir.getTempFile({suffix: ".p12"})
      if (isUrl) {
        await httpExecutor.download(urlOrBase64, tempFile)
      }
      else {
        await outputFile(tempFile, Buffer.from(urlOrBase64, "base64"))
      }
      return tempFile
    }
    else {
      file = urlOrBase64
    }
  }

  file = path.resolve(currentDir, file)
  const stat = await statOrNull(file)
  if (stat == null) {
    throw new Error(`${file} doesn't exist`)
  }
  else if (!stat.isFile()) {
    throw new Error(`${file} not a file`)
  }
  else {
    return file
  }
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:42,代码来源:codeSign.ts

示例2: test

test("Bintray upload", async () => {
  const version = versionNumber()

  const tmpDir = new TmpDir()
  const artifactPath = await tmpDir.getTempFile({suffix: ".icns"})
  await copyFile(iconPath, artifactPath)

  //noinspection SpellCheckingInspection
  const publisher = new BintrayPublisher(publishContext, {provider: "bintray", owner: "actperepo", package: "test", repo: "generic", token: "5df2cadec86dff91392e4c419540785813c3db15"}, version)
  try {
    await publisher.upload(artifactPath, Arch.x64)
    await publisher.upload(artifactPath, Arch.x64)
  }
  finally {
    try {
      await publisher.deleteRelease()
    }
    finally {
      await tmpDir.cleanup()
    }
  }
})
开发者ID:jwheare,项目名称:electron-builder,代码行数:22,代码来源:ArtifactPublisherTest.ts

示例3: test

test("Bintray upload", async () => {
  const version = "42.0.0"
  const tmpDir = new TmpDir("artifact-publisher-test")
  const artifactPath = await tmpDir.getTempFile({suffix: " test-space.icns"})
  await copyFile(iconPath, artifactPath)

  //noinspection SpellCheckingInspection
  const publisher = new BintrayPublisher(publishContext, {provider: "bintray", owner: "actperepo", package: "test", repo: "generic", token: "5df2cadec86dff91392e4c419540785813c3db15"}, version)
  try {
    // force delete old version to ensure that test doesn't depend on previous runs
    await publisher.deleteRelease(true)
    await publisher.upload({file: artifactPath, arch: Arch.x64})
    await publisher.upload({file: artifactPath, arch: Arch.x64})
  }
  finally {
    try {
      await publisher.deleteRelease(false)
    }
    finally {
      await tmpDir.cleanup()
    }
  }
})
开发者ID:electron-userland,项目名称:electron-builder,代码行数:23,代码来源:ArtifactPublisherTest.ts


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