• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fs-extra-p.unlink函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra-p.writeFile函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra-p.symlink函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap