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


TypeScript TmpDir.getTempFile方法代码示例

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


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

示例1: transformBackgroundFileIfNeed

export async function transformBackgroundFileIfNeed(file: string, tmpDir: TmpDir): Promise<string> {
  if (file.endsWith(".tiff") || file.endsWith(".TIFF")) {
    return file
  }

  const retinaFile = file.replace(/\.([a-z]+)$/, "@2x.$1")
  if (await exists(retinaFile)) {
    const tiffFile = await tmpDir.getTempFile({suffix: ".tiff"})
    await exec("tiffutil", ["-cathidpicheck", file, retinaFile, "-out", tiffFile])
    return tiffFile
  }

  return file
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:14,代码来源:dmgUtil.ts

示例2: 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 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 InvalidConfigurationError(`${file} doesn't exist`)
  }
  else if (!stat.isFile()) {
    throw new InvalidConfigurationError(`${file} not a file`)
  }
  else {
    return file
  }
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:42,代码来源:codesign.ts

示例3: tar

export async function tar(compression: CompressionLevel | any | any, format: string, outFile: string, dirToArchive: string, isMacApp: boolean, tempDirManager: TmpDir): Promise<void> {
  const tarFile = await tempDirManager.getTempFile({suffix: ".tar"})
  const tarArgs = debug7zArgs("a")
  tarArgs.push(tarFile)
  tarArgs.push(path.basename(dirToArchive))

  await Promise.all([
    exec(path7za, tarArgs, {cwd: path.dirname(dirToArchive)}),
    // remove file before - 7z doesn't overwrite file, but update
    unlinkIfExists(outFile),
  ])

  if (!isMacApp) {
    await exec(path7za, ["rn", tarFile, path.basename(dirToArchive), path.basename(outFile, `.${format}`)])
  }

  if (format === "tar.lz") {
    // noinspection SpellCheckingInspection
    let lzipPath = "lzip"
    if (process.platform === "darwin") {
      lzipPath = path.join(await getLinuxToolsPath(), "bin", lzipPath)
    }
    await exec(lzipPath, [compression === "store" ? "-1" : "-9", "--keep" /* keep (don't delete) input files */, tarFile])
    // bloody lzip creates file in the same dir where input file with postfix `.lz`, option --output doesn't work
    await move(`${tarFile}.lz`, outFile)
    return
  }

  const args = compute7zCompressArgs(format === "tar.xz" ? "xz" : (format === "tar.bz2" ? "bzip2" : "gzip"), {
    isRegularFile: true,
    method: "DEFAULT",
    compression,
  })
  args.push(outFile, tarFile)
  await exec(path7za, args, {
    cwd: path.dirname(dirToArchive),
  }, debug7z.enabled)
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:38,代码来源:archive.ts

示例4: async

test.ifAll.ifDevOrLinuxCi("download to nonexistent dir", async () => {
  const tempFile = await tmpDir.getTempFile()
  await httpExecutor.download("https://drive.google.com/uc?export=download&id=0Bz3JwZ-jqfRONTkzTGlsMkM2TlE", tempFile)
  await assertThat(tempFile).isFile()
})
开发者ID:jwheare,项目名称:electron-builder,代码行数:5,代码来源:httpRequestTest.ts


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