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


TypeScript Promise.promisify方法代码示例

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


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

示例1: packApp

  protected async packApp(options: any, appOutDir: string) {
    await super.packApp(options, appOutDir)

    if (process.platform !== "linux" && this.options.cscLink != null && this.options.cscKeyPassword != null) {
      const filename = this.appName + ".exe"
      log(`Signing ${filename}`)
      await BluebirdPromise.promisify(sign)({
        path: path.join(appOutDir, filename),
        cert: (await this.certFilePromise)!,
        password: this.options.cscKeyPassword,
        name: this.appName,
        site: await this.computePackageUrl(),
        overwrite: true,
      })
    }
  }
开发者ID:luningCloud,项目名称:electron-builder,代码行数:16,代码来源:winPackager.ts

示例2: doPack

  protected async doPack(outDir: string, appOutDir: string, arch: string) {
    await super.doPack(outDir, appOutDir, arch)

    if (process.platform === "darwin" && this.options.cscLink != null && this.options.cscKeyPassword != null) {
      const filename = this.appName + ".exe"
      log(`Signing ${filename}`)
      await BluebirdPromise.promisify(sign)({
        path: path.join(appOutDir, filename),
        cert: await this.certFilePromise,
        password: this.options.cscKeyPassword,
        name: this.appName,
        site: await this.computePackageUrl(),
        hash: ["sha256"],
        overwrite: true,
      })
    }
  }
开发者ID:waifei,项目名称:electron-builder,代码行数:17,代码来源:winPackager.ts

示例3: doPack

  protected async doPack(options: ElectronPackagerOptions, outDir: string, appOutDir: string, arch: Arch, customBuildOptions: WinBuildOptions) {
    await super.doPack(options, outDir, appOutDir, arch, customBuildOptions)

    const cert = await this.certFilePromise
    if (cert != null) {
      const filename = `${this.appName}.exe`
      log(`Signing ${filename}`)
      await BluebirdPromise.promisify(sign)({
        path: path.join(appOutDir, filename),
        cert: cert,
        password: this.options.cscKeyPassword!,
        name: this.appName,
        site: await this.computePackageUrl(),
        overwrite: true,
        hash: this.customBuildOptions.signingHashAlgorithms,
      })
    }
  }
开发者ID:bright-spark,项目名称:electron-builder,代码行数:18,代码来源:winPackager.ts

示例4: require

import { InfoRetriever, ProjectMetadataProvider } from "./repositoryInfo"
import { AppMetadata, DevMetadata, Platform, getProductName } from "./metadata"
import EventEmitter = NodeJS.EventEmitter
import { Promise as BluebirdPromise } from "bluebird"
import * as path from "path"
import packager = require("electron-packager-tf")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")

const pack = BluebirdPromise.promisify(packager)

export interface PackagerOptions {
  arch?: string

  dist?: boolean
  githubToken?: string

  sign?: string

  platform?: Array<string>
  target?: Array<string>

  appDir?: string

  projectDir?: string

  cscLink?: string
  csaLink?: string
  cscKeyPassword?: string
}
开发者ID:pauliusuza,项目名称:electron-builder,代码行数:31,代码来源:platformPackager.ts

示例5: doSign

 //noinspection JSMethodCanBeStatic
 protected async doSign(opts: SignOptions): Promise<any> {
   return BluebirdPromise.promisify(sign)(opts)
 }
开发者ID:mairanteodoro,项目名称:electron-builder,代码行数:4,代码来源:winPackager.ts

示例6: require

import * as path from "path"
import { readJson, stat } from "fs-extra-p"
import { yellow } from "chalk"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")

export const log = console.log

export function warn(message: string) {
  console.warn(yellow(message))
}

const DEFAULT_APP_DIR_NAMES = ["app", "www"]

export const readPackageJson = BluebirdPromise.promisify(readPackageJsonAsync)

export function installDependencies(appDir: string, electronVersion: string, arch: string = process.arch, command: string = "install"): BluebirdPromise<any> {
  log((command === "install" ? "Installing" : "Rebuilding") + " app dependencies for arch %s to %s", arch, appDir)
  const gypHome = path.join(os.homedir(), ".electron-gyp")
  const env = Object.assign({}, process.env, {
    npm_config_disturl: "https://atom.io/download/atom-shell",
    npm_config_target: electronVersion,
    npm_config_runtime: "electron",
    npm_config_arch: arch,
    HOME: gypHome,
    USERPROFILE: gypHome,
  })

  let npmExecPath = process.env.npm_execpath || process.env.NPM_CLI_JS
  const npmExecArgs = [command, "--production"]
开发者ID:Lange,项目名称:electron-builder,代码行数:31,代码来源:util.ts

示例7: require

import { Promise as BluebirdPromise } from "bluebird"
import { emptyDir } from "fs-extra-p"
import { warn } from "../util/log"
import { AppInfo } from "../appInfo"

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

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../util/awaiter")

export interface ElectronPackagerOptions {
  "extend-info"?: string
  "app-category-type"?: string

  protocols?: any

  appInfo: AppInfo

  icon?: string;

  "helper-bundle-id"?: string | null;

  ignore?: any
}

const supportedPlatforms: any = {
  // Maps to module ID for each platform (lazy-required if used)
  darwin: "./mac",
  linux: "./linux",
  mas: "./mac", // map to darwin
开发者ID:SimplyAhmazing,项目名称:electron-builder,代码行数:31,代码来源:dirPackager.ts

示例8: build

  async build(arch: Arch, outDir: string, appOutDir: string) {
    const packager = this.packager

    const iconPath = await packager.getIconPath()
    const appInfo = packager.appInfo
    const version = appInfo.version
    const archSuffix = getArchSuffix(arch)
    const installerPath = path.join(outDir, `${appInfo.productName} Setup ${version}${archSuffix}.exe`)
    // const archiveFile = path.join(this.outDir, `.${packager.metadata.name}-${packager.metadata.version}${archSuffix}.7z`)
    const archiveFile = path.join(outDir, `app.7z`)

    const guid = this.nsisOptions.guid || await BluebirdPromise.promisify(uuid5)({namespace: ELECTRON_BUILDER_NS_UUID, name: appInfo.id})
    const productName = appInfo.productName
    const defines: any = {
      APP_ID: appInfo.id,
      APP_GUID: guid,
      PRODUCT_NAME: productName,
      INST_DIR_NAME: sanitizeFileName(productName),
      APP_DESCRIPTION: appInfo.description,
      APP_ARCHIVE: archiveFile,
      VERSION: version,

      MUI_ICON: iconPath,
      MUI_UNICON: iconPath,

      COMPANY_NAME: appInfo.companyName,
    }

    if (this.nsisOptions.perMachine === true) {
      defines.MULTIUSER_INSTALLMODE_DEFAULT_ALLUSERS = null
    }
    else {
      defines.MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER = null
    }

    if (this.nsisOptions.allowElevation !== false) {
      defines.MULTIUSER_INSTALLMODE_ALLOW_ELEVATION = null
    }

    // Error: invalid VIProductVersion format, should be X.X.X.X
    // so, we must strip beta
    const parsedVersion = new semver.SemVer(appInfo.version)
    const commands: any = {
      OutFile: `"${installerPath}"`,
      // LoadLanguageFile: '"${NSISDIR}/Contrib/Language files/English.nlf"',
      VIProductVersion: `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}.${appInfo.buildNumber || "0"}`,
      // VIFileVersion: packager.appInfo.buildVersion,
      VIAddVersionKey: [
        `ProductName "${appInfo.productName}"`,
        `CompanyName "${appInfo.versionString.CompanyName}"`,
        `LegalCopyright "${appInfo.versionString.LegalCopyright}"`,
        `FileDescription "${appInfo.description}"`,
        `FileVersion "${appInfo.buildVersion}"`,
      ],
    }

    if (packager.devMetadata.build.compression === "store") {
      commands.SetCompress = "off"
      defines.COMPRESS = "off"
    }
    else {
      commands.SetCompressor = "lzma"
      // default is 8: test app installer size 37.2 vs 36 if dict size 64
      commands.SetCompressorDictSize = "64"

      defines.COMPRESS = "auto"
    }

    await subTask("Packing app into 7z archive", archiveApp(packager.devMetadata.build.compression, "7z", archiveFile, appOutDir, true))

    const oneClick = this.nsisOptions.oneClick !== false
    if (oneClick) {
      defines.ONE_CLICK = null
    }

    debug(defines)
    debug(commands)

    await subTask(`Executing makensis`, NsisTarget.executeMakensis(defines, commands))
    await packager.sign(installerPath)

    this.packager.dispatchArtifactCreated(installerPath, `${appInfo.name}-Setup-${version}${archSuffix}.exe`)
  }
开发者ID:TheAlphaNerd,项目名称:electron-builder,代码行数:83,代码来源:nsis.ts

示例9: createApp

import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
import { rename } from "fs-extra-p"
import { ElectronPackagerOptions } from "./dirPackager"

const rcedit: any = BluebirdPromise.promisify(require("rcedit"))

export function createApp(opts: ElectronPackagerOptions, appOutDir: string, initializeApp: () => Promise<any>) {
  const newExePath = path.join(appOutDir, `${opts.appInfo.productFilename}.exe`)
  return BluebirdPromise.all([
    initializeApp(),
    rename(path.join(appOutDir, "electron.exe"), newExePath)
      .then(() => {
        const appInfo = opts.appInfo
        return rcedit(newExePath, {
          "version-string": appInfo.versionString,
          "file-version": appInfo.buildVersion,
          "product-version": appInfo.version,
          icon: opts.icon
        })
      })
  ])
}
开发者ID:SimplyAhmazing,项目名称:electron-builder,代码行数:23,代码来源:win32.ts

示例10: _download

import { Socket } from "net"
import { IncomingMessage, ClientRequest } from "http"
import * as https from "https"
import { createWriteStream, ensureDir } from "fs-extra-p"
import { parse as parseUrl } from "url"
import { Promise as BluebirdPromise } from "bluebird"
import * as path from "path"

const maxRedirects = 10

export const download = BluebirdPromise.promisify(_download)

function _download(url: string, destination: string, callback: (error: Error) => void): void {
  doDownload(url, destination, 0, callback)
}

export function addTimeOutHandler(request: ClientRequest, callback: (error: Error) => void) {
  request.on("socket", function (socket: Socket) {
    socket.setTimeout(60 * 1000, () => {
      callback(new Error("Request timed out"))
      request.abort()
    })
  })
}

function doDownload(url: string, destination: string, redirectCount: number, callback: (error: Error) => void) {
  const ensureDirPromise = ensureDir(path.dirname(destination))

  const parsedUrl = parseUrl(url)
  // user-agent must be specified, otherwise some host can return 401 unauthorised
  const request = https.request({
开发者ID:MatthijsvandenBosch,项目名称:electron-builder,代码行数:31,代码来源:httpRequest.ts


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