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


TypeScript fs-extra-p.unlink函數代碼示例

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


在下文中一共展示了unlink函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: deleteOldElectronVersion

async function deleteOldElectronVersion(): Promise<any> {
  if (!process.env.CI) {
    return
  }

  const cacheDir = path.join(require("os").homedir(), ".electron")
  try {
    const deletePromises: Array<Promise<any>> = []
    for (let file of (await readdir(cacheDir))) {
      if (file.endsWith(".zip") && !file.includes(electronVersion)) {
        console.log("Remove old electron " + file)
        deletePromises.push(unlink(path.join(cacheDir, file)))
      }
    }
    return BluebirdPromise.all(deletePromises)
  }
  catch (e) {
    if (e.code === "ENOENT") {
      return []
    }
    else {
      throw e
    }
  }
}
開發者ID:MathijsvVelde,項目名稱:electron-builder,代碼行數:25,代碼來源:runTests.ts

示例2: deleteOldElectronVersion

async function deleteOldElectronVersion(): Promise<any> {
  if (!isCi) {
    return
  }

  const cacheDir = require("env-paths")("electron", {suffix: ""}).cache
  try {
    const deletePromises: Array<Promise<any>> = []
    for (const file of (await readdir(cacheDir))) {
      if (file.endsWith(".zip") && !file.includes(ELECTRON_VERSION)) {
        console.log(`Remove old electron ${file}`)
        deletePromises.push(unlink(path.join(cacheDir, file)))
      }
    }
    return await BluebirdPromise.all(deletePromises)
  }
  catch (e) {
    if (e.code === "ENOENT") {
      return []
    }
    else {
      throw e
    }
  }
}
開發者ID:djpereira,項目名稱:electron-builder,代碼行數:25,代碼來源:runTests.ts

示例3: unlink

 return BluebirdPromise.map(readdir(cacheDir), (file): any => {
   if (file.endsWith(".zip") && !file.includes(ELECTRON_VERSION)) {
     console.log(`Remove old electron ${file}`)
     return unlink(path.join(cacheDir, file))
   }
   return null
 })
開發者ID:jwheare,項目名稱:electron-builder,代碼行數:7,代碼來源:downloadElectron.ts

示例4: modifyPackageJson

export async function modifyPackageJson(projectDir: string, task: (data: any) => void, isApp = false): Promise<any> {
  const file = isApp ? path.join(projectDir, "app", "package.json") : path.join(projectDir, "package.json")
  const data = await readJson(file)
  task(data)
  // because copied as hard link
  await unlink(file)
  return await writeJson(file, data)
}
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:8,代碼來源:packTester.ts

示例5:

 .then(it => {
   const deletePromises: Array<Promise<any>> = []
   for (let file of it) {
     if (file.endsWith(".zip") && !file.includes(electronVersion)) {
       console.log("Remove old electron " + file)
       deletePromises.push(fs.unlink(path.join(cacheDir, file)))
     }
   }
   return BluebirdPromise.all(deletePromises)
 })
開發者ID:waifei,項目名稱:electron-builder,代碼行數:10,代碼來源:runTests.ts

示例6: msi

async function msi(options: SquirrelOptions, nupkgPath: string, setupPath: string, outputDirectory: string, outFile: string) {
  const args = [
    "--createMsi", nupkgPath,
    "--bootstrapperExe", setupPath
  ]
  await exec(process.platform === "win32" ? path.join(options.vendorPath, "Update.com") : "mono", prepareArgs(args, path.join(options.vendorPath, "Update-Mono.exe")))
  //noinspection SpellCheckingInspection
  await exec(path.join(options.vendorPath, "candle.exe"), ["-nologo", "-ext", "WixNetFxExtension", "-out", "Setup.wixobj", "Setup.wxs"], {
    cwd: outputDirectory,
  })
  //noinspection SpellCheckingInspection
  await exec(path.join(options.vendorPath, "light.exe"), ["-ext", "WixNetFxExtension", "-sval", "-out", outFile, "Setup.wixobj"], {
    cwd: outputDirectory,
  })

  //noinspection SpellCheckingInspection
  await BluebirdPromise.all([
    unlink(path.join(outputDirectory, "Setup.wxs")),
    unlink(path.join(outputDirectory, "Setup.wixobj")),
    unlink(path.join(outputDirectory, outFile.replace(".msi", ".wixpdb"))).catch(e => debug(e.toString())),
  ])
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:22,代碼來源:squirrelPack.ts

示例7: copyFile

    projectDirCreated: async projectDir => {
      const resourceDir = path.join(projectDir, "build")
      await copyFile(path.join(getDmgTemplatePath(), "background.tiff"), path.join(resourceDir, "background.tiff"))

      async function extractPng(index: number, suffix: string) {
        await exec("tiffutil", ["-extract", index.toString(), path.join(getDmgTemplatePath(), "background.tiff")], {
          cwd: projectDir
        })
        await exec("sips", ["-s", "format", "png", "out.tiff", "--out", `background${suffix}.png`], {
          cwd: projectDir
        })
      }

      await extractPng(0, "")
      await extractPng(1, "@2x")
      await unlink(path.join(resourceDir, "background.tiff"))
    },
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:17,代碼來源:dmgTest.ts

示例8: async

      task: async (destinationFile, downloadOptions, packageFile, removeTempDirIfAny) => {
        const packageInfo = fileInfo.packageInfo
        const isWebInstaller = packageInfo != null && packageFile != null
        if (isWebInstaller || await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider)) {
          await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)
        }

        const signatureVerificationStatus = await this.verifySignature(destinationFile)
        if (signatureVerificationStatus != null) {
          await removeTempDirIfAny()
          // noinspection ThrowInsideFinallyBlockJS
          throw newError(`New version ${downloadUpdateOptions.updateInfoAndProvider.info.version} is not signed by the application owner: ${signatureVerificationStatus}`, "ERR_UPDATER_INVALID_SIGNATURE")
        }

        if (isWebInstaller) {
          if (await this.differentialDownloadWebPackage(packageInfo!!, packageFile!!, provider)) {
            try {
              await this.httpExecutor.download(new URL(packageInfo!!.path), packageFile!!, {
                headers: downloadUpdateOptions.requestHeaders,
                cancellationToken: downloadUpdateOptions.cancellationToken,
                sha512: packageInfo!!.sha512,
              })
            }
            catch (e) {
              try {
                await unlink(packageFile!!)
              }
              catch (ignored) {
                // ignore
              }

              throw e
            }
          }
        }
      },
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:36,代碼來源:NsisUpdater.ts

示例9: unlink

 projectDirCreated: projectDir => Promise.all([
   unlink(path.join(projectDir, "build", "icon.ico")),
   remove(path.join(projectDir, "build", "icons")),
 ]),
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:4,代碼來源:winPackagerTest.ts

示例10: unlink

 projectDirCreated: projectDir => Promise.all([
   unlink(path.join(projectDir, "build", "icon.icns")),
   unlink(path.join(projectDir, "build", "icon.ico")),
   copy(path.join(projectDir, "build", "icons", "512x512.png"), path.join(projectDir, "build", "icon.png"))
     .then(() => remove(path.join(projectDir, "build", "icons")))
 ]),
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:6,代碼來源:macIconTest.ts

示例11: unlinkIfExists

export function unlinkIfExists(file: string) {
  return unlink(file)
    .catch(() => {/* ignore */})
}
開發者ID:electron-userland,項目名稱:electron-builder,代碼行數:4,代碼來源:fs.ts

示例12: doGetBin

// we cache in the global location - in the home dir, not in the node_modules/.cache (https://www.npmjs.com/package/find-cache-dir) because
// * don't need to find node_modules
// * don't pollute user project dir (important in case of 1-package.json project structure)
// * simplify/speed-up tests (don't download fpm for each test project)
async function doGetBin(name: string, dirName: string, url: string, checksum: string): Promise<string> {
  const cachePath = path.join(getCacheDirectory(), name)
  const dirPath = path.join(cachePath, dirName)

  const logFlags = {path: dirPath}

  const dirStat = await statOrNull(dirPath)
  if (dirStat != null && dirStat.isDirectory()) {
    log.debug(logFlags, "found existing")
    return dirPath
  }

  log.info({...logFlags, url}, "downloading")

  // 7z cannot be extracted from the input stream, temp file is required
  const tempUnpackDir = path.join(cachePath, getTempName())
  const archiveName = `${tempUnpackDir}.7z`
  // 7z doesn't create out dir, so, we don't create dir in parallel to download - dir creation will create parent dirs for archive file also
  await emptyDir(tempUnpackDir)
  const options: DownloadOptions = {
    skipDirCreation: true,
    cancellationToken: new CancellationToken(),
  }

  if (checksum.length === 64 && !checksum.includes("+") && !checksum.includes("Z") && !checksum.includes("=")) {
    (options as any).sha2 = checksum
  }
  else {
    (options as any).sha512 = checksum
  }

  for (let attemptNumber = 1; attemptNumber < 4; attemptNumber++) {
    try {
      await httpExecutor.download(url, archiveName, options)
    }
    catch (e) {
      if (attemptNumber >= 3) {
        throw e
      }

      log.warn({...logFlags, attempt: attemptNumber}, `cannot download: ${e}`)
      await new BluebirdPromise((resolve, reject) => {
        setTimeout(() =>
          httpExecutor
            .download(url, archiveName, options)
            .then(resolve).catch(reject), 1000 * attemptNumber)
      })
    }
  }

  await spawn(path7za, debug7zArgs("x").concat(archiveName, `-o${tempUnpackDir}`), {
    cwd: cachePath,
  })

  await BluebirdPromise.all([
    rename(tempUnpackDir, dirPath)
      .catch(e => log.debug({...logFlags, tempUnpackDir, e}, `cannot move downloaded into final location (another process downloaded faster?)`)),
    unlink(archiveName),
  ])

  log.debug(logFlags, `downloaded`)
  return dirPath
}
開發者ID:ledinhphuong,項目名稱:electron-builder,代碼行數:67,代碼來源:binDownload.ts


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