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

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

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

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



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

示例1: pathSorter

  packed: async context => {
    const pkgPath = path.join(context.outDir, "Test App ßW-1.1.0.pkg")
    const fileList = pathSorter(parseFileList(await exec("pkgutil", ["--payload-files", pkgPath]), false))
    expect(fileList).toMatchSnapshot()

    const unpackedDir = path.join(context.outDir, "pkg-unpacked")
    await exec("pkgutil", ["--expand", pkgPath, unpackedDir])

    const m: any = BluebirdPromise.promisify(parseString)
    const info = await m(await readFile(path.join(unpackedDir, "Distribution"), "utf8"), {
      explicitRoot: false,
      explicitArray: false,
      mergeAttrs: true,
    })
    delete info["pkg-ref"][0]["bundle-version"].bundle.CFBundleVersion
    delete info["pkg-ref"][1].installKBytes
    delete info.product.version
    expect(info).toMatchSnapshot()

    const scriptDir = path.join(unpackedDir, "org.electron-builder.testApp.pkg", "Scripts")
    await BluebirdPromise.all([
      assertThat(path.join(scriptDir, "postinstall")).isFile(),
      assertThat(path.join(scriptDir, "preinstall")).isFile(),
    ])
  }
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:25,代码来源:macArchiveTest.ts


示例2: readEmbeddedBlockMapData

export async function readEmbeddedBlockMapData(file: string) {
  const fd = await open(file, "r")
  try {
    const fileSize = (await fstat(fd)).size
    const sizeBuffer = Buffer.allocUnsafe(4)
    await read(fd, sizeBuffer, 0, sizeBuffer.length, fileSize - sizeBuffer.length)

    const dataBuffer = Buffer.allocUnsafe(sizeBuffer.readUInt32BE(0))
    await read(fd, dataBuffer, 0, dataBuffer.length, fileSize - sizeBuffer.length - dataBuffer.length)
    await close(fd)

    const inflateRaw: any = BluebirdPromise.promisify(require("zlib").inflateRaw)
    return (await inflateRaw(dataBuffer)).toString()
  }
  catch (e) {
    await close(fd)
    throw e
  }
}
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:19,代码来源:blockMapApi.ts


示例3: safeLoad

      packed: async context => {
        const outDir = context.outDir
        outDirs.push(outDir)
        const targetOutDir = path.join(outDir, "nsis-web")
        const updateInfoFile = path.join(targetOutDir, "latest.yml")

        const updateInfo: UpdateInfo = safeLoad(await readFile(updateInfoFile, "utf-8"))
        const fd = await open(path.join(targetOutDir, `TestApp-${version}-x64.nsis.7z`), "r")
        try {
          const packageInfo = updateInfo.packages!!.x64
          const buffer = Buffer.allocUnsafe(packageInfo.blockMapSize!!)
          await read(fd, buffer, 0, buffer.length, packageInfo.size - buffer.length)
          const inflateRaw: any = BluebirdPromise.promisify(require("zlib").inflateRaw)
          const blockMapData = (await inflateRaw(buffer)).toString()
          await writeFile(path.join(outDir, "win-unpacked", BLOCK_MAP_FILE_NAME), blockMapData)
        }
        finally {
          await close(fd)
        }
      }
开发者ID:jwheare,项目名称:electron-builder,代码行数:20,代码来源:differentialUpdateTest.ts


示例4:

import BluebirdPromise from "bluebird-lst"
import { BlockMapDataHolder, configureRequestOptionsFromUrl, createHttpError, DigestTransform, HttpExecutor } from "builder-util-runtime"
import { BlockMap } from "builder-util-runtime/out/blockMapApi"
import { close, closeSync, createWriteStream, open } from "fs-extra-p"
import { OutgoingHttpHeaders, RequestOptions } from "http"
import { Logger } from "../main"
import { copyData } from "./DataSplitter"
import { computeOperations, Operation, OperationKind } from "./downloadPlanBuilder"
import { checkIsRangesSupported, executeTasks } from "./multipleRangeDownloader"

const inflateRaw: any = BluebirdPromise.promisify(require("zlib").inflateRaw)

export class DifferentialDownloaderOptions {
  readonly oldFile: string
  readonly newUrl: string
  readonly logger: Logger
  readonly newFile: string

  readonly requestHeaders: OutgoingHttpHeaders | null

  readonly useMultipleRangeRequest?: boolean
}

export abstract class DifferentialDownloader {
  private readonly baseRequestOptions: RequestOptions

  fileMetadataBuffer: Buffer | null

  private readonly logger: Logger

  // noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:31,代码来源:DifferentialDownloader.ts


示例5: addValue

import BluebirdPromise from "bluebird-lst"
import { log } from "builder-util"
import { CONCURRENCY } from "builder-util/out/fs"
import { ensureDir } from "fs-extra-p"
import * as path from "path"
import { getDestinationPath } from "../util/appFileCopier"
import { NODE_MODULES_PATTERN, ResolvedFileSet } from "../util/AppFileCopierHelper"

const isBinaryFile: any = BluebirdPromise.promisify(require("isbinaryfile"))

function addValue(map: Map<string, Array<string>>, key: string, value: string) {
  let list = map.get(key)
  if (list == null) {
    list = [value]
    map.set(key, list)
  }
  else {
    list.push(value)
  }
}

/** @internal */
export async function detectUnpackedDirs(fileSet: ResolvedFileSet, autoUnpackDirs: Set<string>, unpackedDest: string, rootForAppFilesWithoutAsar: string) {
  const dirToCreate = new Map<string, Array<string>>()
  const metadata = fileSet.metadata

  function addParents(child: string, root: string) {
    child = path.dirname(child)
    if (autoUnpackDirs.has(child)) {
      return
    }
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:31,代码来源:unpackDetector.ts


示例6: require

import BluebirdPromise from "bluebird-lst"
import { emptyDir, readdir, readJson, removeSync, unlink } from "fs-extra-p"
import isCi from "is-ci"
import * as path from "path"
import { ELECTRON_VERSION, TEST_DIR } from "./config"

// we set NODE_PATH in this file, so, we cannot use 'out/util' path here
const util = require("../../../packages/electron-builder-util/out/util")
const isEmptyOrSpaces = util.isEmptyOrSpaces

const downloadElectron: (options: any) => Promise<any> = BluebirdPromise.promisify(require("electron-download-tf"))

runTests()
  .catch(error => {
    console.error(error.stack || error)
    process.exit(1)
  })

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)))
      }
开发者ID:djpereira,项目名称:electron-builder,代码行数:31,代码来源:runTests.ts


示例7: Application

    <id>TestApp</id>
    <version>${convertVersion(appInfo.version)}</version>
    <title>${appInfo.productName}</title>
    <authors>Foo Bar</authors>
    <owners>Foo Bar</owners>
    <iconUrl>https://raw.githubusercontent.com/szwacz/electron-boilerplate/master/resources/windows/icon.ico</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Test Application (test quite “ #378)</description>
    <copyright>Copyright © ${new Date().getFullYear()} Foo Bar</copyright>
    <projectUrl>http://foo.example.com</projectUrl>
  </metadata>
</package>`)
  }
}

const execShell: any = BluebirdPromise.promisify(require("child_process").exec)

async function getTarExecutable() {
  return process.platform === "darwin" ? path.join(await getLinuxToolsPath(), "bin", "gtar") : "tar"
}

async function getContents(packageFile: string) {
  const result = await execShell(`ar p '${packageFile}' data.tar.xz | ${await getTarExecutable()} -t -I'${path7x}'`, {
    maxBuffer: 10 * 1024 * 1024,
    env: {
      ...process.env,
      SZA_PATH: path7za,
    }
  })
  return pathSorter(parseFileList(result, true)
    .filter(it => !(it.includes(`/locales/`) || it.includes(`/libgcrypt`)))
开发者ID:electron-userland,项目名称:electron-builder,代码行数:31,代码来源:packTester.ts


示例8: electronDownloader

 packager.electronDownloader = options => {
   if (electronDownloader ==  null) {
     electronDownloader = BluebirdPromise.promisify(require("electron-download-tf"))
   }
   return electronDownloader(options)
 }
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:6,代码来源:builder.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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