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


TypeScript TmpDir.getTempDir方法代码示例

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


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

示例1: async

test.ifAll.ifDevOrWinCi("web installer", async () => {
  let outDirs: Array<string> = []

  async function buildApp(version: string, tmpDir: TmpDir) {
    await assertPack("test-app-one", {
      targets: Platform.WINDOWS.createTarget(["nsis-web"], Arch.x64),
      config: {
        extraMetadata: {
          version,
        },
        // package in any case compressed, customization is explicitly disabled - "do not allow to change compression level to avoid different packages"
        compression: process.env.COMPRESSION as any || "store",
        publish: {
          provider: "s3",
          bucket: "develar",
          path: "test",
        },
      },
    }, {
      signedWin: true,
      packed: async context => {
        outDirs.push(context.outDir)
      },
      tmpDir,
    })
  }

  if (process.env.__SKIP_BUILD == null) {
    const tmpDir = new TmpDir("differential-updater-test")
    try {
      await buildApp(OLD_VERSION_NUMBER, tmpDir)
      // move dist temporarily out of project dir
      const oldDir = await tmpDir.getTempDir()
      await move(outDirs[0], oldDir)
      outDirs[0] = oldDir

      await buildApp("1.0.1", tmpDir)
    }
    catch (e) {
      await tmpDir.cleanup()
      throw e
    }

    // move old dist to new project as oldDist - simplify development (no need to guess where old dist located in the temp fs)
    const oldDir = path.join(outDirs[1], "..", "oldDist")
    await move(outDirs[0], oldDir)
    outDirs[0] = oldDir

    await move(path.join(oldDir, "nsis-web", `TestApp-${OLD_VERSION_NUMBER}-x64.nsis.7z`), path.join(getTestUpdaterCacheDir(oldDir), testAppCacheDirName, "package.7z"))
  }
  else {
    nsisWebDifferentialUpdateTestFakeSnapshot()
    outDirs = [
      path.join(process.env.TEST_APP_TMP_DIR!!, "oldDist"),
      path.join(process.env.TEST_APP_TMP_DIR!!, "dist"),
    ]
  }

  await testBlockMap(outDirs[0], path.join(outDirs[1], "nsis-web"), NsisUpdater, "win-unpacked", Platform.WINDOWS)
})
开发者ID:electron-userland,项目名称:electron-builder,代码行数:60,代码来源:differentialUpdateTest.ts

示例2: doBuild

async function doBuild(outDirs: Array<string>, targets: Map<Platform, Map<Arch, Array<string>>>, tmpDir: TmpDir, extraConfig?: Configuration | null) {
  await buildApp("1.0.0", outDirs, targets, tmpDir, extraConfig)
  try {
    // move dist temporarily out of project dir
    const oldDir = await tmpDir.getTempDir()
    await move(outDirs[0], oldDir)
    outDirs[0] = oldDir

    await buildApp("1.0.1", outDirs, targets, tmpDir, extraConfig)
  }
  catch (e) {
    await tmpDir.cleanup()
    throw e
  }

  // move old dist to new project as oldDist - simplify development (no need to guess where old dist located in the temp fs)
  const oldDir = path.join(outDirs[1], "..", "oldDist")
  await move(outDirs[0], oldDir)
  outDirs[0] = oldDir
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:20,代码来源:differentialUpdateTest.ts

示例3: async

test.ifAll.ifDevOrWinCi("web installer", async () => {
  process.env.TEST_UPDATER_PLATFORM = "win32"

  let outDirs: Array<string> = []

  async function buildApp(version: string) {
    await assertPack("test-app-one", {
      targets: Platform.WINDOWS.createTarget(["nsis-web"], Arch.x64),
      config: {
        extraMetadata: {
          version,
        },
        // package in any case compressed, customization is explicitly disabled - "do not allow to change compression level to avoid different packages"
        compression: process.env.COMPRESSION as any || "store",
        publish: {
          provider: "s3",
          bucket: "develar",
          path: "test",
        },
      },
    }, {
      signed: true,
      packed: async context => {
        outDirs.push(context.outDir)
      }
    })
  }

  if (process.env.__SKIP_BUILD == null) {
    await buildApp("1.0.0")

    const tmpDir = new TmpDir()
    try {
      // move dist temporarily out of project dir
      const oldDir = await tmpDir.getTempDir()
      await rename(outDirs[0], oldDir)
      outDirs[0] = oldDir

      await buildApp("1.0.1")
    }
    catch (e) {
      await tmpDir.cleanup()
      throw e
    }

    // move old dist to new project as oldDist - simplify development (no need to guess where old dist located in the temp fs)
    const oldDir = path.join(outDirs[1], "..", "oldDist")
    await rename(outDirs[0], oldDir)
    outDirs[0] = oldDir

    await rename(path.join(oldDir, "nsis-web", "TestApp-1.0.0-x64.nsis.7z"), path.join(oldDir, "win-unpacked", "package.7z"))
  }
  else {
    // to  avoid snapshot mismatch (since in this node app is not packed)
    expect({
      win: [
        {
          file: "latest.yml",
          fileContent: {
            files: [
              {
                sha512: "@sha512",
                url: "Test App ßW Web Setup 1.0.0.exe",
              },
            ],
            packages: {
              x64: {
                blockMapSize: "@blockMapSize",
                headerSize: "@headerSize",
                path: "TestApp-1.0.0-x64.nsis.7z",
                sha512: "@sha512",
                size: "@size",
              },
            },
            path: "Test App ßW Web Setup 1.0.0.exe",
            releaseDate: "@releaseDate",
            sha2: "@sha2",
            sha512: "@sha512",
            version: "1.0.0",
          },
        },
        {
          arch: "x64",
          file: "Test App ßW Web Setup 1.0.0.exe",
          safeArtifactName: "TestApp-WebSetup-1.0.0.exe",
          updateInfo: {
            packages: {
              x64: {
                blockMapSize: "@blockMapSize",
                headerSize: "@headerSize",
                path: "TestApp-1.0.0-x64.nsis.7z",
                sha512: "@sha512",
                size: "@size",
              },
            },
          },
        },
        {
          arch: "x64",
          file: "TestApp-1.0.0-x64.nsis.7z",
//.........这里部分代码省略.........
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:101,代码来源:differentialUpdateTest.ts

示例4: async

test.ifAll.ifDevOrWinCi("web installer", async () => {
  let outDirs: Array<string> = []

  async function buildApp(version: string) {
    await assertPack("test-app-one", {
      targets: Platform.WINDOWS.createTarget(["nsis-web"], Arch.x64),
      config: {
        extraMetadata: {
          version,
        },
        // package in any case compressed, customization is explicitly disabled - "do not allow to change compression level to avoid different packages"
        compression: process.env.COMPRESSION as any || "store",
        publish: {
          provider: "s3",
          bucket: "develar",
          path: "test",
        },
        nsis: {
          differentialPackage: true,
        },
      }
    }, {
      packed: async context => {
        const outDir = context.outDir
        outDirs.push(outDir)
        const targetOutDir = path.join(outDir, "nsis-web")
        const updateInfoFile = path.join(targetOutDir, "latest.yml")

        const updateInfo: UpdateInfo = safeLoad(await readFile(updateInfoFile, "utf-8"))
        const fd = await open(path.join(targetOutDir, `TestApp-${version}-x64.nsis.7z`), "r")
        try {
          const packageInfo = updateInfo.packages!!.x64
          const buffer = Buffer.allocUnsafe(packageInfo.blockMapSize!!)
          await read(fd, buffer, 0, buffer.length, packageInfo.size - buffer.length)
          const inflateRaw: any = BluebirdPromise.promisify(require("zlib").inflateRaw)
          const blockMapData = (await inflateRaw(buffer)).toString()
          await writeFile(path.join(outDir, "win-unpacked", BLOCK_MAP_FILE_NAME), blockMapData)
        }
        finally {
          await close(fd)
        }
      }
    })
  }

  if (process.env.__SKIP_BUILD == null) {
    await buildApp("1.0.0")

    const tmpDir = new TmpDir()
    try {
      // move dist temporarily out of project dir
      const oldDir = await tmpDir.getTempDir()
      await rename(outDirs[0], oldDir)
      outDirs[0] = oldDir

      await buildApp("1.0.1")
    }
    catch (e) {
      await tmpDir.cleanup()
      throw e
    }

    // move old dist to new project as oldDist - simplify development (no need to guess where old dist located in the temp fs)
    const oldDir = path.join(outDirs[1], "..", "oldDist")
    await rename(outDirs[0], oldDir)
    outDirs[0] = oldDir

    await rename(path.join(oldDir, "nsis-web", "TestApp-1.0.0-x64.nsis.7z"), path.join(oldDir, "win-unpacked", "package.7z"))
  }
  else {
    // to  avoid snapshot mismatch (since in this node app is not packed)
    expect({
      win: [
        {
          file: "latest.yml",
          fileContent: {
            version: "1.0.0",
            path: "Test App ßW Web Setup 1.0.0.exe",
            packages: {
              x64: {
                file: "TestApp-1.0.0-x64.nsis.7z"
              }
            },
          }
        },
        {
          file: "Test App ßW Web Setup 1.0.0.exe",
          packageFiles: {
            x64: {
              file: "TestApp-1.0.0-x64.nsis.7z"
            }
          },
          arch: "x64",
          safeArtifactName: "TestApp-WebSetup-1.0.0.exe"
        },
        {
          file: "TestApp-1.0.0-x64.nsis.7z",
          arch: "x64"
        }
      ]
//.........这里部分代码省略.........
开发者ID:jwheare,项目名称:electron-builder,代码行数:101,代码来源:differentialUpdateTest.ts


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