本文整理汇总了TypeScript中electron-builder-util.use函数的典型用法代码示例。如果您正苦于以下问题:TypeScript use函数的具体用法?TypeScript use怎么用?TypeScript use使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了use函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: signAndEditResources
async signAndEditResources(file: string) {
const appInfo = this.appInfo
const args = [
file,
"--set-version-string", "CompanyName", appInfo.companyName,
"--set-version-string", "FileDescription", appInfo.productName,
"--set-version-string", "ProductName", appInfo.productName,
"--set-version-string", "InternalName", path.basename(appInfo.productFilename, ".exe"),
"--set-version-string", "LegalCopyright", appInfo.copyright,
"--set-version-string", "OriginalFilename", "",
"--set-file-version", appInfo.buildVersion,
"--set-product-version", appInfo.versionInWeirdWindowsForm,
]
use(this.platformSpecificBuildOptions.legalTrademarks, it => args.push("--set-version-string", "LegalTrademarks", it!))
use(await this.getIconPath(), it => args.push("--set-icon", it))
const rceditExecutable = path.join(await getSignVendorPath(), "rcedit.exe")
const isWin = process.platform === "win32"
if (!isWin) {
args.unshift(rceditExecutable)
}
await exec(isWin ? rceditExecutable : "wine", args)
await this.sign(file)
}
示例2: installAppDeps
export async function installAppDeps(args: any) {
try {
log("electron-builder " + PACKAGE_VERSION)
}
catch (e) {
// error in dev mode without babel
if (!(e instanceof ReferenceError)) {
throw e
}
}
const projectDir = process.cwd()
const config = await getConfig(projectDir, null, null, null)
const muonVersion = config.muonVersion
const results = await BluebirdPromise.all<string>([
computeDefaultAppDirectory(projectDir, use(config.directories, it => it!.app)),
muonVersion == null ? getElectronVersion(projectDir, config) : BluebirdPromise.resolve(muonVersion),
])
// if two package.json â force full install (user wants to install/update app deps in addition to dev)
await installOrRebuild(config, results[0], {
frameworkInfo: {version: results[1], useCustomDist: muonVersion == null},
platform: args.platform,
arch: args.arch,
productionDeps: createLazyProductionDeps(results[0]),
}, results[0] !== projectDir)
}
示例3: main
async function main() {
const args: any = yargs
.option("platform", {
choices: ["linux", "darwin", "win32"],
default: process.platform,
})
.option("arch", {
choices: ["ia32", "x64", "all"],
default: process.arch,
})
.argv
const projectDir = process.cwd()
const config = (await loadConfig(projectDir)) || {}
const results: Array<string> = await BluebirdPromise.all([
computeDefaultAppDirectory(projectDir, use(config.directories, it => it!.app)),
getElectronVersion(config, projectDir)
])
// if two package.json â force full install (user wants to install/update app deps in addition to dev)
await installOrRebuild(config, results[0], results[1], args.platform, args.arch, results[0] !== projectDir)
}
示例4: createMacApp
//.........这里部分代码省略.........
const oldIcon = appPlist.CFBundleIconFile
if (icon != null) {
appPlist.CFBundleIconFile = `${appFilename}.icns`
}
appPlist.CFBundleDisplayName = appInfo.productName
appPlist.CFBundleIdentifier = appBundleIdentifier
appPlist.CFBundleName = appInfo.productName
// https://github.com/electron-userland/electron-builder/issues/1278
appPlist.CFBundleExecutable = !appFilename.endsWith(" Helper") ? appFilename : appFilename.substring(0, appFilename.length - " Helper".length)
helperPlist.CFBundleExecutable = `${appFilename} Helper`
helperEHPlist.CFBundleExecutable = `${appFilename} Helper EH`
helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`
helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
helperEHPlist.CFBundleDisplayName = `${appInfo.productName} Helper EH`
helperNPPlist.CFBundleDisplayName = `${appInfo.productName} Helper NP`
helperPlist.CFBundleIdentifier = helperBundleIdentifier
helperEHPlist.CFBundleIdentifier = `${helperBundleIdentifier}.EH`
helperNPPlist.CFBundleIdentifier = `${helperBundleIdentifier}.NP`
appPlist.CFBundleShortVersionString = appInfo.version
appPlist.CFBundleVersion = appInfo.buildVersion
const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))
if (protocols.length > 0) {
appPlist.CFBundleURLTypes = protocols.map(protocol => {
const schemes = asArray(protocol.schemes)
if (schemes.length === 0) {
throw new Error(`Protocol "${protocol.name}": must be at least one scheme specified`)
}
return {
CFBundleURLName: protocol.name,
CFBundleTypeRole: protocol.role || "Editor",
CFBundleURLSchemes: schemes.slice()
}
})
}
const resourcesPath = path.join(contentsPath, "Resources")
const fileAssociations = packager.fileAssociations
if (fileAssociations.length > 0) {
appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
const extensions = asArray(fileAssociation.ext).map(normalizeExt)
const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)
let iconFile = appPlist.CFBundleIconFile
if (customIcon != null) {
iconFile = path.basename(customIcon)
await copyOrLinkFile(customIcon, path.join(resourcesPath, iconFile))
}
const result = {
CFBundleTypeExtensions: extensions,
CFBundleTypeName: fileAssociation.name || extensions[0],
CFBundleTypeRole: fileAssociation.role || "Editor",
CFBundleTypeIconFile: iconFile
} as any
if (fileAssociation.isPackage) {
result.LSTypeIsPackage = true
}
return result
})
}
use(packager.platformSpecificBuildOptions.category || (buildMetadata as any).category, it => appPlist.LSApplicationCategoryType = it)
appPlist.NSHumanReadableCopyright = appInfo.copyright
if (asarIntegrity != null) {
appPlist.AsarIntegrity = JSON.stringify(asarIntegrity)
}
const promises: Array<Promise<any | n>> = [
writeFile(appPlistFilename, buildPlist(appPlist)),
writeFile(helperPlistFilename, buildPlist(helperPlist)),
writeFile(helperEHPlistFilename, buildPlist(helperEHPlist)),
writeFile(helperNPPlistFilename, buildPlist(helperNPPlist)),
doRename(path.join(contentsPath, "MacOS"), packager.electronDistMacOsExecutableName, appPlist.CFBundleExecutable),
unlinkIfExists(path.join(appOutDir, "LICENSE")),
unlinkIfExists(path.join(appOutDir, "LICENSES.chromium.html")),
]
if (icon != null) {
promises.push(unlinkIfExists(path.join(resourcesPath, oldIcon)))
promises.push(copyFile(icon, path.join(resourcesPath, appPlist.CFBundleIconFile)))
}
await BluebirdPromise.all(promises)
await moveHelpers(frameworksPath, appFilename, packager.electronDistMacOsExecutableName)
const appPath = path.join(appOutDir, `${appFilename}.app`)
await rename(path.dirname(contentsPath), appPath)
// https://github.com/electron-userland/electron-builder/issues/840
const now = Date.now() / 1000
await utimes(appPath, now, now)
}