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


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

本文整理汇总了TypeScript中fs-extra-p.rename函数的典型用法代码示例。如果您正苦于以下问题:TypeScript rename函数的具体用法?TypeScript rename怎么用?TypeScript rename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: rename

 tempDirCreated: projectDir => {
   headerIconPath = path.join(projectDir, "build", "installerHeaderIcon.ico")
   return rename(path.join(projectDir, "headerIcon.ico"), headerIconPath)
 }
开发者ID:jonmak08,项目名称:electron-builder,代码行数:4,代码来源:winPackagerTest.ts

示例2: rename

 .then(() => rename(tmpKeychainPath, keychainPath)),
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:1,代码来源:codeSign.ts

示例3: postInitApp

 protected postInitApp(appOutDir: string): Promise<any> {
   return rename(path.join(appOutDir, this.electronDistExecutableName), path.join(appOutDir, this.executableName))
 }
开发者ID:djpereira,项目名称:electron-builder,代码行数:3,代码来源:linuxPackager.ts

示例4: rename

 projectDirCreated: projectDir => rename(path.join(projectDir, "build", "icon.ico"), path.join(projectDir, "customIcon.ico")),
开发者ID:jwheare,项目名称:electron-builder,代码行数:1,代码来源:winPackagerTest.ts

示例5: createMacApp


//.........这里部分代码省略.........
  const oldIcon = appPlist.CFBundleIconFile
  if (icon != null) {
    appPlist.CFBundleIconFile = `${appFilename}.icns`
  }

  appPlist.CFBundleDisplayName = appInfo.productName
  appPlist.CFBundleIdentifier = appBundleIdentifier
  appPlist.CFBundleName = appInfo.productName

  // https://github.com/electron-userland/electron-builder/issues/1278
  appPlist.CFBundleExecutable = !appFilename.endsWith(" Helper") ? appFilename : appFilename.substring(0, appFilename.length - " Helper".length)

  helperPlist.CFBundleExecutable = `${appFilename} Helper`
  helperEHPlist.CFBundleExecutable = `${appFilename} Helper EH`
  helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`

  helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
  helperEHPlist.CFBundleDisplayName = `${appInfo.productName} Helper EH`
  helperNPPlist.CFBundleDisplayName = `${appInfo.productName} Helper NP`

  helperPlist.CFBundleIdentifier = helperBundleIdentifier
  helperEHPlist.CFBundleIdentifier = `${helperBundleIdentifier}.EH`
  helperNPPlist.CFBundleIdentifier = `${helperBundleIdentifier}.NP`

  appPlist.CFBundleShortVersionString = macOptions.bundleShortVersion || appInfo.version
  appPlist.CFBundleVersion = appInfo.buildVersion

  const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))
  if (protocols.length > 0) {
    appPlist.CFBundleURLTypes = protocols.map(protocol => {
      const schemes = asArray(protocol.schemes)
      if (schemes.length === 0) {
        throw new Error(`Protocol "${protocol.name}": must be at least one scheme specified`)
      }
      return {
        CFBundleURLName: protocol.name,
        CFBundleTypeRole: protocol.role || "Editor",
        CFBundleURLSchemes: schemes.slice()
      }
    })
  }

  const resourcesPath = path.join(contentsPath, "Resources")

  const fileAssociations = packager.fileAssociations
  if (fileAssociations.length > 0) {
    appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
      const extensions = asArray(fileAssociation.ext).map(normalizeExt)
      const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)
      let iconFile = appPlist.CFBundleIconFile
      if (customIcon != null) {
        iconFile = path.basename(customIcon)
        await copyOrLinkFile(customIcon, path.join(resourcesPath, iconFile))
      }

      const result = {
        CFBundleTypeExtensions: extensions,
        CFBundleTypeName: fileAssociation.name || extensions[0],
        CFBundleTypeRole: fileAssociation.role || "Editor",
        CFBundleTypeIconFile: iconFile
      } as any

      if (fileAssociation.isPackage) {
        result.LSTypeIsPackage = true
      }
      return result
    })
  }

  use(packager.platformSpecificBuildOptions.category || (buildMetadata as any).category, it => appPlist.LSApplicationCategoryType = it)
  appPlist.NSHumanReadableCopyright = appInfo.copyright

  if (asarIntegrity != null) {
    appPlist.AsarIntegrity = JSON.stringify(asarIntegrity)
  }

  const promises: Array<Promise<any | null | undefined>> = [
    writeFile(appPlistFilename, buildPlist(appPlist)),
    writeFile(helperPlistFilename, buildPlist(helperPlist)),
    writeFile(helperEHPlistFilename, buildPlist(helperEHPlist)),
    writeFile(helperNPPlistFilename, buildPlist(helperNPPlist)),
    doRename(path.join(contentsPath, "MacOS"), packager.electronDistMacOsExecutableName, appPlist.CFBundleExecutable),
    unlinkIfExists(path.join(appOutDir, "LICENSE")),
    unlinkIfExists(path.join(appOutDir, "LICENSES.chromium.html")),
  ]

  if (icon != null) {
    promises.push(unlinkIfExists(path.join(resourcesPath, oldIcon)))
    promises.push(copyFile(icon, path.join(resourcesPath, appPlist.CFBundleIconFile)))
  }

  await BluebirdPromise.all(promises)

  await moveHelpers(frameworksPath, appFilename, packager.electronDistMacOsExecutableName)
  const appPath = path.join(appOutDir, `${appFilename}.app`)
  await rename(path.dirname(contentsPath), appPath)
  // https://github.com/electron-userland/electron-builder/issues/840
  const now = Date.now() / 1000
  await utimes(appPath, now, now)
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:101,代码来源:mac.ts

示例6: 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

示例7: packageInDistributableFormat

  async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise<any> {
    let iconUrl = this.devMetadata.build.iconUrl
    if (!iconUrl) {
      if (this.customBuildOptions != null) {
        iconUrl = this.customBuildOptions.iconUrl
      }
      if (!iconUrl) {
        if (this.info.repositoryInfo != null) {
          const info = await this.info.repositoryInfo.getInfo(this)
          if (info != null) {
            iconUrl = `https://raw.githubusercontent.com/${info.user}/${info.project}/master/${this.relativeBuildResourcesDirname}/icon.ico`
          }
        }

        if (!iconUrl) {
          throw new Error("iconUrl is not specified, please see https://github.com/electron-userland/electron-builder#in-short")
        }
      }
    }

    const certificateFile = await this.certFilePromise
    const version = this.metadata.version
    const installerOutDir = WinPackager.computeDistOut(outDir, arch)
    const archSuffix = arch === "x64" ? "" : ("-" + arch)
    const options = Object.assign({
      name: this.metadata.name,
      productName: this.appName,
      exe: this.appName + ".exe",
      title: this.appName,
      appDirectory: appOutDir,
      outputDirectory: installerOutDir,
      version: version,
      description: this.metadata.description,
      authors: this.metadata.author.name,
      iconUrl: iconUrl,
      setupIcon: path.join(this.buildResourcesDir, "icon.ico"),
      certificateFile: certificateFile,
      certificatePassword: this.options.cscKeyPassword,
      fixUpPaths: false,
      usePackageJson: false,
      noMsi: true,
    }, this.customBuildOptions)

    try {
      await require("electron-winstaller-fixed").createWindowsInstaller(options)
    }
    catch (e) {
      if (!e.message.includes("Unable to set icon")) {
        throw e
      }
      else {
        let fileInfo: Stats
        try {
          fileInfo = await stat(options.setupIcon)
        }
        catch (e) {
          throw new Error("Please specify correct setupIcon, file " + options.setupIcon + " not found")
        }

        if (fileInfo.isDirectory()) {
          throw new Error("Please specify correct setupIcon, " + options.setupIcon + " is a directory")
        }
      }
    }

    const releasesFile = path.join(installerOutDir, "RELEASES")
    const nupkgPathOriginal = this.metadata.name + "-" + version + "-full.nupkg"
    const nupkgPathWithArch = this.metadata.name + "-" + version + archSuffix + "-full.nupkg"

    async function changeFileNameInTheReleasesFile(): Promise<void> {
      const data = (await readFile(releasesFile, "utf8")).replace(new RegExp(" " + nupkgPathOriginal + " ", "g"), " " + nupkgPathWithArch + " ")
      await writeFile(releasesFile, data)
    }

    const promises: Array<Promise<any>> = [
      rename(path.join(installerOutDir, "Setup.exe"), path.join(installerOutDir, `${this.appName}Setup-${version}${archSuffix}.exe`))
        .then(it => this.dispatchArtifactCreated(it, `${this.metadata.name}Setup-${version}${archSuffix}.exe`)),
    ]

    if (archSuffix === "") {
      this.dispatchArtifactCreated(path.join(installerOutDir, nupkgPathOriginal))
      this.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"))
    }
    else {
      promises.push(
        rename(path.join(installerOutDir, nupkgPathOriginal), path.join(installerOutDir, nupkgPathWithArch))
          .then(it => this.dispatchArtifactCreated(it))
      )
      promises.push(
        changeFileNameInTheReleasesFile()
          .then(() => copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32")))
          .then(it => this.dispatchArtifactCreated(it))
      )
    }

    await BluebirdPromise.all(promises)
  }
开发者ID:bundyo,项目名称:electron-builder,代码行数:97,代码来源:winPackager.ts

示例8: rename

 projectDirCreated: async projectDir => {
   await rename(path.join(projectDir, "build", "icons", "256x256.png"), path.join(projectDir, "build", "icon.png"))
   await remove(path.join(projectDir, "build", "icons"))
   await rename(path.join(projectDir, "build"), path.join(projectDir, "icons"))
 },
开发者ID:electron-userland,项目名称:electron-builder,代码行数:5,代码来源:linuxPackagerTest.ts


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