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

TypeScript bluebird-lst.map函数代码示例

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

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



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

示例1: readScopedDir

async function readScopedDir(dir: string): Promise<Array<string> | null> {
  let files: Array<string>
  try {
    files = (await readdir(dir)).filter(it => !it.startsWith(".") && !knownAlwaysIgnoredDevDeps.has(it))
  }
  catch (e) {
    // error indicates that nothing is installed here
    return null
  }

  files.sort()

  const scopes = files.filter(it => it.startsWith("@") && it !== "@types")
  if (scopes.length === 0) {
    return files
  }

  const result = files.filter(it => !it.startsWith("@"))
  const scopeFileList = await BluebirdPromise.map(scopes, it => readdir(path.join(dir, it)))
  for (let i = 0; i < scopes.length; i++) {
    const list = scopeFileList[i]
    list.sort()
    for (const file of list) {
      if (!file.startsWith(".")) {
        result.push(`${scopes[i]}/${file}`)
      }
    }
  }

  return result
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:31,代码来源:packageDependencies.ts


示例2: writeUpdateInfoFiles

export async function writeUpdateInfoFiles(updateInfoFileTasks: Array<UpdateInfoFileTask>, packager: Packager) {
  // zip must be first and zip info must be used for old path/sha512 properties in the update info
  updateInfoFileTasks.sort((a, b) => (a.info.files[0].url.endsWith(".zip") ? 0 : 100) - (b.info.files[0].url.endsWith(".zip") ? 0 : 100))

  const updateChannelFileToInfo = new Map<string, UpdateInfoFileTask>()
  for (const task of updateInfoFileTasks) {
    const key = `${task.file}@${safeStringifyJson(task.publishConfiguration)}`
    const existingTask = updateChannelFileToInfo.get(key)
    if (existingTask == null) {
      updateChannelFileToInfo.set(key, task)
      continue
    }

    existingTask.info.files.push(...task.info.files)
  }

  const releaseDate = new Date().toISOString()
  await BluebirdPromise.map(updateChannelFileToInfo.values(), async task => {
    task.info.releaseDate = releaseDate
    const fileContent = Buffer.from(serializeToYaml(task.info))
    await outputFile(task.file, fileContent)
    packager.dispatchArtifactCreated({
      file: task.file,
      fileContent,
      arch: null,
      packager: task.packager,
      target: null,
      publishConfig: task.publishConfiguration,
    })
  }, {concurrency: 4})
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:31,代码来源:updateInfoBuilder.ts


示例3: computeFileSets

export async function computeFileSets(matchers: Array<FileMatcher>, transformer: FileTransformer, packager: Packager, isElectronCompile: boolean): Promise<Array<ResolvedFileSet>> {
  const fileSets: Array<ResolvedFileSet> = []
  for (const matcher of matchers) {
    const fileWalker = new AppFileWalker(matcher, packager)

    const fromStat = await statOrNull(fileWalker.matcher.from)
    if (fromStat == null) {
      debug(`Directory ${fileWalker.matcher.from} doesn't exists, skip file copying`)
      continue
    }

    const files = await walk(fileWalker.matcher.from, fileWalker.filter, fileWalker)
    const metadata = fileWalker.metadata

    const transformedFiles = await BluebirdPromise.map(files, it => {
      const fileStat = metadata.get(it)
      return fileStat != null && fileStat.isFile() ? transformer(it) : null
    }, CONCURRENCY)

    fileSets.push({src: fileWalker.matcher.from, files, metadata: fileWalker.metadata, transformedFiles, destination: fileWalker.matcher.to})
  }

  const mainFileSet = fileSets[0]
  if (isElectronCompile) {
    // cache should be first in the asar
    fileSets.unshift(await compileUsingElectronCompile(mainFileSet, packager))
  }
  return fileSets
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:29,代码来源:AppFileCopierHelper.ts


示例4: readScopedDir

async function readScopedDir(dir: string) {
  let files: Array<string>
  try {
    files = (await readdir(dir)).filter(it => !it.startsWith("."))
  }
  catch (e) {
    // error indicates that nothing is installed here
    return []
  }

  files.sort()

  const scopes = files.filter(it => it.startsWith("@"))
  if (scopes.length === 0) {
    return files
  }

  const result = files.filter(it => !it.startsWith("@"))
  const scopeFileList = await BluebirdPromise.map(scopes, it => readdir(path.join(dir, it)))
  for (let i = 0; i < scopes.length; i++) {
    for (const file of scopeFileList[i]) {
      if (!file.startsWith(".")) {
        result.push(`${scopes[i]}/${file}`)
      }
    }
  }

  result.sort()
  return result
}
开发者ID:djpereira,项目名称:electron-builder,代码行数:30,代码来源:readInstalled.ts


示例5: moveHelpers

function moveHelpers(frameworksPath: string, appName: string, prefix: string): Promise<any> {
  return BluebirdPromise.map([" Helper", " Helper EH", " Helper NP"], suffix => {
    const executableBasePath = path.join(frameworksPath, `${prefix}${suffix}.app`, "Contents", "MacOS")
    return doRename(executableBasePath, `${prefix}${suffix}`, appName + suffix)
      .then(() => doRename(frameworksPath, `${prefix}${suffix}.app`, `${appName}${suffix}.app`))
  })
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:7,代码来源:mac.ts


示例6: setPackageVersions

async function setPackageVersions(packages: Array<string>, packageData: Array<any>) {
  const versions = await BluebirdPromise.map(packages, it => exec("yarn", ["info", "--json", it, "dist-tags"])
    .then((it: string) => {
      if (it === "") {
        // {"type":"error","data":"Received invalid response from npm."}
        // not yet published to npm
        return "0.0.1"
      }

      try {
        return JSON.parse(it).data
      }
      catch (e) {
        throw new Error(`Cannot parse ${it}: ${e.stack || e}`)
      }
    }))
  for (let i = 0; i < packages.length; i++) {
    const packageName = packages[i]
    const packageJson = packageData[i]
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion == null || packageJson.version == latestVersion || semver.lt(latestVersion, packageJson.version)) {
      continue
    }

    packageJson.version = latestVersion
    console.log(`Set ${packageName} version to ${latestVersion}`)
    await writeJson(path.join(packageDir, packageName, "package.json"), packageJson, {spaces: 2})
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:30,代码来源:setVersions.ts


示例7: createKeychain

export async function createKeychain({tmpDir, cscLink, cscKeyPassword, cscILink, cscIKeyPassword, currentDir}: CreateKeychainOptions): Promise<CodeSigningInfo> {
  // travis has correct AppleWWDRCA cert
  if (process.env.TRAVIS !== "true") {
    await bundledCertKeychainAdded.value
  }

  const keychainFile = await tmpDir.getTempFile({suffix: ".keychain", disposer: removeKeychain})

  const certLinks = [cscLink]
  if (cscILink != null) {
    certLinks.push(cscILink)
  }

  const certPaths = new Array(certLinks.length)
  const keychainPassword = randomBytes(8).toString("base64")
  const securityCommands = [
    ["create-keychain", "-p", keychainPassword, keychainFile],
    ["unlock-keychain", "-p", keychainPassword, keychainFile],
    ["set-keychain-settings", keychainFile]
  ]

  // https://stackoverflow.com/questions/42484678/codesign-keychain-gets-ignored
  // https://github.com/electron-userland/electron-builder/issues/1457
  const list = await listUserKeychains()
  if (!list.includes(keychainFile)) {
    securityCommands.push(["list-keychains", "-d", "user", "-s", keychainFile].concat(list))
  }

  await BluebirdPromise.all([
    // we do not clear downloaded files - will be removed on tmpDir cleanup automatically. not a security issue since in any case data is available as env variables and protected by password.
    BluebirdPromise.map(certLinks, (link, i) => downloadCertificate(link, tmpDir, currentDir).then(it => certPaths[i] = it)),
    BluebirdPromise.mapSeries(securityCommands, it => exec("security", it))
  ])
  return await importCerts(keychainFile, certPaths, [cscKeyPassword, cscIKeyPassword].filter(it => it != null) as Array<string>)
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:35,代码来源:codeSign.ts


示例8: main

async function main(): Promise<void> {
  const packages = (await readdir(packageDir)).filter(it => !it.includes(".")).sort()
  const devPackageData = await readJson(path.join(rootDir, "package.json"))
  if ((await BluebirdPromise.map(packages, it => check(path.join(packageDir, it), devPackageData))).includes(false)) {
    process.exitCode = 1
  }
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:7,代码来源:checkDeps.ts


示例9: readProjectMetadata

async function readProjectMetadata(packageDir: string) {
  const packageDirs = BluebirdPromise.filter((await readdir(packageDir)).filter(it => !it.includes(".")).sort(), it => {
    return stat(path.join(packageDir, it, "package.json"))
      .then(it => it.isFile())
      .catch(() => false)
  })
  return await BluebirdPromise.map(packageDirs, it => readJson(path.join(packageDir, it, "package.json")), {concurrency: 8})
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:8,代码来源:setVersions.ts


示例10: rebuild

export async function rebuild(appDir: string, options: RebuildOptions) {
  const nativeDeps = await BluebirdPromise.filter(await options.productionDeps!.value, it => exists(path.join(it.path, "binding.gyp")), {concurrency: 8})
  if (nativeDeps.length === 0) {
    log(`No native production dependencies`)
    return
  }

  const platform = options.platform || process.platform
  const arch = options.arch || process.arch
  const additionalArgs = options.additionalArgs

  log(`Rebuilding native production dependencies for ${platform}:${arch}`)

  let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS
  const isYarn = isYarnPath(execPath)
  const execArgs: Array<string> = []
  if (execPath == null) {
    execPath = getPackageToolPath()
  }
  else {
    execArgs.push(execPath)
    execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
  }

  const env = getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true)
  if (isYarn) {
    execArgs.push("run", "install", "--")
    if (additionalArgs != null) {
      execArgs.push(...additionalArgs)
    }
    await BluebirdPromise.map(nativeDeps, dep => {
      log(`Rebuilding native dependency ${dep.name}`)
      return spawn(execPath!, execArgs, {
        cwd: dep.path,
        env,
      })
        .catch(error => {
          if (dep.optional) {
            warn(`Cannot build optional native dep ${dep.name}`)
          }
          else {
            throw error
          }
        })
    }, {concurrency: process.platform === "win32" ? 1 : 2})
  }
  else {
    execArgs.push("rebuild")
    if (additionalArgs != null) {
      execArgs.push(...additionalArgs)
    }
    execArgs.push(...nativeDeps.map(it => it.name))
    await spawn(execPath, execArgs, {
      cwd: appDir,
      env,
    })
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:58,代码来源:yarn.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript bluebird-lst.mapSeries函数代码示例发布时间:2022-05-25
下一篇:
TypeScript bluebird-lst.filter函数代码示例发布时间: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