本文整理汇总了TypeScript中bluebird.Promise.map方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Promise.map方法的具体用法?TypeScript Promise.map怎么用?TypeScript Promise.map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bluebird.Promise
的用法示例。
在下文中一共展示了Promise.map方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: copyExtraResources
protected async copyExtraResources(appOutDir: string, arch: string): Promise<Array<string>> {
let resourcesDir = appOutDir
if (this.platform === Platform.OSX) {
resourcesDir = path.join(resourcesDir, this.appName + ".app", "Contents", "Resources")
}
return await BluebirdPromise.map(await this.getExtraResources(arch), it => copy(path.join(this.projectDir, it), path.join(resourcesDir, it)))
}
示例2: pack
async pack(outDir: string, appOutDir: string, arch: string): Promise<any> {
// we must check icon before pack because electron-packager uses icon and it leads to cryptic error message "spawn wine ENOENT"
await this.iconPath
if (!this.options.dist) {
return super.pack(outDir, appOutDir, arch)
}
const installerOut = computeDistOut(outDir, arch)
log("Removing %s", installerOut)
await
BluebirdPromise.all([
this.doPack(outDir, appOutDir, arch),
emptyDir(installerOut)
])
const extraResources = await this.copyExtraResources(appOutDir, arch)
if (extraResources.length > 0) {
this.extraNuGetFileSources = BluebirdPromise.map(extraResources, file => {
return stat(file)
.then(it => {
const relativePath = path.relative(appOutDir, file)
const src = it.isDirectory() ? `${relativePath}${path.sep}**` : relativePath
return `<file src="${src}" target="lib\\net45\\${relativePath.replace(/\//g, "\\")}"/>`
})
})
}
}
示例3: moveHelpers
function moveHelpers (frameworksPath: string, appName: string) {
return BluebirdPromise.map([" Helper", " Helper EH", " Helper NP"], suffix => {
const executableBasePath = path.join(frameworksPath, `Electron${suffix}.app`, "Contents", "MacOS")
return doRename(executableBasePath, `Electron${suffix}`, appName + suffix)
.then(() => doRename(frameworksPath, `Electron${suffix}.app`, `${appName}${suffix}.app`))
})
}
示例4: createKeychain
export function createKeychain(keychainName: string, cscLink: string, cscKeyPassword: string, cscILink?: string, cscIKeyPassword?: string, csaLink?: string): Promise<CodeSigningInfo> {
const certLinks = [csaLink || "https://developer.apple.com/certificationauthority/AppleWWDRCA.cer"]
if (csaLink == null) {
certLinks.push("https://startssl.com/certs/sca.code2.crt", "https://startssl.com/certs/sca.code3.crt")
}
certLinks.push(cscLink)
if (cscILink != null) {
certLinks.push(cscILink)
}
const certPaths = certLinks.map(it => path.join(tmpdir(), randomString() + (it.endsWith(".cer") ? ".cer" : ".p12")))
const keychainPassword = randomString()
return executeFinally(BluebirdPromise.all([
BluebirdPromise.map(certPaths, (p, i) => download(certLinks[i], p)),
BluebirdPromise.mapSeries([
["create-keychain", "-p", keychainPassword, keychainName],
["unlock-keychain", "-p", keychainPassword, keychainName],
["set-keychain-settings", "-t", "3600", "-u", keychainName]
], it => exec("security", it))
])
.then(() => importCerts(keychainName, certPaths, [cscKeyPassword, cscIKeyPassword].filter(it => it != null))),
errorOccurred => {
const tasks = certPaths.map(it => deleteFile(it, true))
if (errorOccurred) {
tasks.push(deleteKeychain(keychainName))
}
return all(tasks)
})
}
示例5: pack
async pack(platform: string, outDir: string, appOutDir: string, arch: string): Promise<any> {
const version = this.metadata.version
let buildVersion = version
const buildNumber = process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM
if (buildNumber != null) {
buildVersion += "." + buildNumber
}
const options = Object.assign({
dir: this.info.appDir,
out: outDir,
name: this.appName,
platform: platform,
arch: arch,
version: this.info.electronVersion,
icon: path.join(this.buildResourcesDir, "icon"),
asar: true,
overwrite: true,
"app-version": version,
"build-version": buildVersion,
"version-string": {
CompanyName: this.metadata.author.name,
FileDescription: this.metadata.description,
ProductVersion: version,
FileVersion: buildVersion,
ProductName: this.appName,
InternalName: this.appName,
}
}, this.metadata.build, {"tmpdir": false})
// this option only for windows-installer
delete options.iconUrl
await pack(options)
const buildMetadata: any = this.devMetadata.build
let extraResources: Array<string> = buildMetadata == null ? null : buildMetadata.extraResources
const platformSpecificExtraResources = this.customBuildOptions == null ? null : this.customBuildOptions.extraResources
if (platformSpecificExtraResources != null) {
extraResources = extraResources == null ? platformSpecificExtraResources : extraResources.concat(platformSpecificExtraResources)
}
if (extraResources != null) {
const expandedPatterns = extraResources.map(it => it
.replace(/\$\{arch\}/g, arch)
.replace(/\$\{os\}/g, this.platform.buildConfigurationKey))
await BluebirdPromise.map(await globby(expandedPatterns, {cwd: this.projectDir}), it => {
let resourcesDir = appOutDir
if (platform === "darwin") {
resourcesDir = path.join(resourcesDir, this.appName + ".app", "Contents", "Resources")
}
return copy(path.join(this.projectDir, it), path.join(resourcesDir, it))
})
}
}
示例6: 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`))
}