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


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

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


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

示例1: Set

    .then((it: any) => {
      const devDeps = Object.keys(it.devDependencies)
      const filtered = new Set()
      /*eslint prefer-const: 0*/
      for (let name of devDeps) {
        filtered.add(path.join(rootDir, "node_modules", name))
      }

      filtered.add(path.join(rootDir, "node_modules", ".bin"))

      return fs.copy(path.join(rootDir, "node_modules"), testNodeModules, {
        filter: it => {
          if (it.includes("node_modules" + path.sep + "babel-")) {
            return false
          }
          return !filtered.has(it)
        }
      })
    })
開發者ID:Lange,項目名稱:electron-builder,代碼行數:19,代碼來源:runTests.ts

示例2: copyDependencies

// npm is very slow and not reliable - so, just copy and then prune dev dependencies
async function copyDependencies() {
  await emptyDir(testNodeModules)
  const devDeps = Object.keys((await readJson(path.join(rootDir, "package.json"), "utf-8")).devDependencies)
  const filtered = new Set()
  /*eslint prefer-const: 0*/
  for (let name of devDeps) {
    filtered.add(path.join(rootDir, "node_modules", name))
  }

  filtered.add(path.join(rootDir, "node_modules", ".bin"))

  return copy(path.join(rootDir, "node_modules"), testNodeModules, {
    filter: it => {
      if (it.includes("node_modules" + path.sep + "babel-")) {
        return false
      }
      return !filtered.has(it)
    }
  })
}
開發者ID:MathijsvVelde,項目名稱:electron-builder,代碼行數:21,代碼來源:runTests.ts

示例3: assertPack

export async function assertPack(fixtureName: string, platform: string | Array<string>, packagerOptions?: PackagerOptions, useTempDir?: boolean, tempDirCreated?: (projectDir: string) => Promise<any>) {
  let projectDir = path.join(__dirname, "..", "..", "fixtures", fixtureName)
  // const isDoNotUseTempDir = platform === "darwin"
  const customTmpDir = process.env.TEST_APP_TMP_DIR
  if (useTempDir) {
    // non-osx test uses the same dir as osx test, but we cannot share node_modules (because tests executed in parallel)
    const dir = customTmpDir == null ? path.join(tmpdir(), tmpDirPrefix + fixtureName + "-" + tmpDirCounter++) : path.resolve(customTmpDir)
    if (customTmpDir != null) {
      console.log("Custom temp dir used: %s", customTmpDir)
    }
    await emptyDir(dir)
    await copy(projectDir, dir, {
      filter: it => {
        const basename = path.basename(it)
        return basename !== "dist" && basename !== "node_modules" && basename[0] !== "."
      }
    })
    projectDir = dir
  }

  try {
    if (tempDirCreated != null) {
      await tempDirCreated(projectDir)
    }

    const platforms = Array.isArray(platform) ? platform : [platform]
    await packAndCheck(projectDir, platforms, packagerOptions)
  }
  finally {
    if (useTempDir && customTmpDir == null) {
      try {
        await remove(projectDir)
      }
      catch (e) {
        console.warn("Cannot delete temporary directory " + projectDir + ": " + (e.stack || e))
      }
    }
  }
}
開發者ID:TakT,項目名稱:electron-builder,代碼行數:39,代碼來源:packTester.ts

示例4: createApp

export async function createApp(opts: ElectronPackagerOptions, appOutDir: string, initializeApp: () => Promise<any>) {
  const appInfo = opts.appInfo
  const appFilename = appInfo.productFilename

  const contentsPath = path.join(appOutDir, "Electron.app", "Contents")
  const frameworksPath = path.join(contentsPath, "Frameworks")

  const appPlistFilename = path.join(contentsPath, "Info.plist")
  const helperPlistFilename = path.join(frameworksPath, "Electron Helper.app", "Contents", "Info.plist")
  const helperEHPlistFilename = path.join(frameworksPath, "Electron Helper EH.app", "Contents", "Info.plist")
  const helperNPPlistFilename = path.join(frameworksPath, "Electron Helper NP.app", "Contents", "Info.plist")

  const result = await BluebirdPromise.all<any | n>([
    initializeApp(),
    BluebirdPromise.map<any | null>([appPlistFilename, helperPlistFilename, helperEHPlistFilename, helperNPPlistFilename, opts["extend-info"]], it => it == null ? it : readFile(it, "utf8"))
  ])
  const fileContents: Array<string> = result[1]!
  const appPlist = parsePlist(fileContents[0])
  const helperPlist = parsePlist(fileContents[1])
  const helperEHPlist = parsePlist(fileContents[2])
  const helperNPPlist = parsePlist(fileContents[3])

  // If an extend-info file was supplied, copy its contents in first
  if (fileContents[4] != null) {
    Object.assign(appPlist, parsePlist(fileContents[4]))
  }

  // Now set fields based on explicit options

  const appBundleIdentifier = filterCFBundleIdentifier(appInfo.id)
  const helperBundleIdentifier = filterCFBundleIdentifier(opts["helper-bundle-id"] || `${appBundleIdentifier}.helper`)

  const buildVersion = appInfo.buildVersion
  const appCategoryType = opts["app-category-type"]
  const humanReadableCopyright = appInfo.copyright

  appPlist.CFBundleDisplayName = appInfo.productName
  appPlist.CFBundleIdentifier = appBundleIdentifier
  appPlist.CFBundleName = appInfo.productName
  helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
  helperPlist.CFBundleIdentifier = helperBundleIdentifier
  appPlist.CFBundleExecutable = appFilename
  helperPlist.CFBundleName = appInfo.productName
  helperPlist.CFBundleExecutable = `${appFilename} Helper`
  helperEHPlist.CFBundleDisplayName = `${appFilename} Helper EH`
  helperEHPlist.CFBundleIdentifier = `${helperBundleIdentifier}.EH`
  helperEHPlist.CFBundleName = `${appInfo.productName} Helper EH`
  helperEHPlist.CFBundleExecutable = `${appFilename} Helper EH`
  helperNPPlist.CFBundleDisplayName = `${appInfo.productName} Helper NP`
  helperNPPlist.CFBundleIdentifier = `${helperBundleIdentifier}.NP`
  helperNPPlist.CFBundleName = `${appInfo.productName} Helper NP`
  helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`

  if (appInfo.version != null) {
    appPlist.CFBundleShortVersionString = appPlist.CFBundleVersion = appInfo.version
  }

  if (buildVersion != null) {
    appPlist.CFBundleVersion = buildVersion
  }

  if (opts.protocols && opts.protocols.length) {
    appPlist.CFBundleURLTypes = opts.protocols.map(function (protocol: any) {
      return {
        CFBundleURLName: protocol.name,
        CFBundleURLSchemes: [].concat(protocol.schemes)
      }
    })
  }

  if (appCategoryType) {
    appPlist.LSApplicationCategoryType = appCategoryType
  }

  if (humanReadableCopyright) {
    appPlist.NSHumanReadableCopyright = humanReadableCopyright
  }

  const promises: Array<BluebirdPromise<any | n>> = [
    writeFile(appPlistFilename, buildPlist(appPlist)),
    writeFile(helperPlistFilename, buildPlist(helperPlist)),
    writeFile(helperEHPlistFilename, buildPlist(helperEHPlist)),
    writeFile(helperNPPlistFilename, buildPlist(helperNPPlist)),
    doRename(path.join(contentsPath, "MacOS"), "Electron", appPlist.CFBundleExecutable)
  ]

  if (opts.icon != null) {
    promises.push(copy(opts.icon, path.join(contentsPath, "Resources", appPlist.CFBundleIconFile)))
  }

  await BluebirdPromise.all(promises)

  await moveHelpers(frameworksPath, appFilename)
  await rename(path.dirname(contentsPath), path.join(appOutDir, `${appFilename}.app`))
}
開發者ID:SimplyAhmazing,項目名稱:electron-builder,代碼行數:95,代碼來源:mac.ts

示例5: copy

 return await BluebirdPromise.map(await this.getExtraResources(arch), it => copy(path.join(this.projectDir, it), path.join(resourcesDir, it)))
開發者ID:atietje,項目名稱:electron-builder,代碼行數:1,代碼來源:platformPackager.ts

示例6: copy

 .then(() => copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32")))
開發者ID:alatzidis,項目名稱:electron-builder,代碼行數:1,代碼來源:winPackager.ts

示例7: copy

 tempDirCreated: projectDir => {
   installerHeaderPath = path.join(projectDir, "build", "installerHeader.bmp")
   return copy(getTestAsset("installerHeader.bmp"), installerHeaderPath)
 }
開發者ID:amilajack,項目名稱:electron-builder,代碼行數:4,代碼來源:winPackagerTest.ts

示例8: copyFiltered

export function copyFiltered(src: string, destination: string, filter: (file: string) => boolean, dereference: boolean): Promise<any> {
  return copy(src, destination, {
    dereference: dereference,
    filter: filter
  })
}
開發者ID:SimplyAhmazing,項目名稱:electron-builder,代碼行數:6,代碼來源:filter.ts

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


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