diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml
index c044210381a..c38047cd6c0 100644
--- a/.idea/dictionaries/develar.xml
+++ b/.idea/dictionaries/develar.xml
@@ -50,6 +50,7 @@
insertmacro
installmode
instdir
+ ircs
isbinaryfile
joliet
keyserver
diff --git a/docs/Options.md b/docs/Options.md
index 70527acf950..695ca96d320 100644
--- a/docs/Options.md
+++ b/docs/Options.md
@@ -58,7 +58,8 @@ Here documented only `electron-builder` specific options:
| files |
A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the [app directory](#MetadataDirectories-app), which specifies which files to include when copying files to create the package.
See [File Patterns](#multiple-glob-patterns).
| extraResources | A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the project directory, when specified, copy the file or directory with matching names directly into the app’s resources directory (Contents/Resources
for MacOS, resources
for Linux/Windows).
Glob rules the same as for [files](#multiple-glob-patterns).
| extraFiles | The same as [extraResources](#BuildMetadata-extraResources) but copy into the app's content directory (`Contents` for MacOS, root directory for Linux/Windows).
-| fileAssociations | File associations. See [.build.fileAssociations](#FileAssociation).
+| fileAssociations | The file associations. See [.build.fileAssociations](#FileAssociation).
+| protocols | The URL protocol scheme(s) to associate the app with. See [.build.protocol](#Protocol).
| mac | See [.build.mac](#MacOptions).
| dmg | See [.build.dmg](#DmgOptions).
| mas | See [.build.mas](#MasBuildOptions).
@@ -172,6 +173,16 @@ NSIS only, [in progress](/~https://github.com/electron-userland/electron-builder/i
| description | *windows-only.* The description.
| icon | *windows-only.* The path to icon (`.ico`), relative to `build` (build resources directory). Defaults to `${ext}.ico`.
+
+### `.build.protocols`
+
+macOS only.
+
+| Name | Description
+| --- | ---
+| **name** | The name. e.g. `IRC server URL`
+| **schemes** | The schemes. e.g. `["irc", "ircs"]`
+
## `.directories`
| Name | Description
diff --git a/src/metadata.ts b/src/metadata.ts
index 9455507a688..d9009c67b31 100755
--- a/src/metadata.ts
+++ b/src/metadata.ts
@@ -145,10 +145,15 @@ export interface BuildMetadata {
readonly extraFiles?: Array | string | null
/*
- File associations. See [.build.fileAssociations](#FileAssociation).
+ The file associations. See [.build.fileAssociations](#FileAssociation).
*/
readonly fileAssociations?: Array | FileAssociation
+ /*
+ The URL protocol scheme(s) to associate the app with. See [.build.protocol](#Protocol).
+ */
+ readonly protocols?: Array | Protocol
+
/*
See [.build.mac](#MacOptions).
*/
@@ -490,12 +495,12 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions {
*/
export interface FileAssociation {
/*
- The extension (minus the leading period). e.g. `png`
+ The extension (minus the leading period). e.g. `png`.
*/
readonly ext: string
/*
- The name. e.g. `PNG`
+ The name. e.g. `PNG`.
*/
readonly name: string
@@ -510,6 +515,23 @@ export interface FileAssociation {
readonly icon?: string
}
+/*
+ ### `.build.protocols`
+
+ macOS only.
+ */
+export interface Protocol {
+ /*
+ The name. e.g. `IRC server URL`.
+ */
+ readonly name: string
+
+ /*
+ The schemes. e.g. `["irc", "ircs"]`.
+ */
+ readonly schemes: Array
+}
+
/*
## `.directories`
*/
diff --git a/src/packager/dirPackager.ts b/src/packager/dirPackager.ts
index d8cc1c9720e..7716b228407 100644
--- a/src/packager/dirPackager.ts
+++ b/src/packager/dirPackager.ts
@@ -3,6 +3,7 @@ import { emptyDir } from "fs-extra-p"
import { warn } from "../util/log"
import { AppInfo } from "../appInfo"
import { PlatformPackager } from "../platformPackager"
+import { Protocol } from "../metadata"
const downloadElectron: (options: any) => Promise = BluebirdPromise.promisify(require("electron-download"))
const extract: any = BluebirdPromise.promisify(require("extract-zip"))
@@ -13,8 +14,6 @@ const __awaiter = require("../util/awaiter")
export interface ElectronPackagerOptions {
"extend-info"?: string
- protocols?: any
-
appInfo: AppInfo
platformPackager: PlatformPackager
diff --git a/src/packager/mac.ts b/src/packager/mac.ts
index 4a85dc1dc30..816f37350ad 100644
--- a/src/packager/mac.ts
+++ b/src/packager/mac.ts
@@ -3,7 +3,7 @@ import { rename, readFile, writeFile, copy } from "fs-extra-p"
import * as path from "path"
import { parse as parsePlist, build as buildPlist } from "plist"
import { Promise as BluebirdPromise } from "bluebird"
-import { use } from "../util/util"
+import { use, asArray } from "../util/util"
//noinspection JSUnusedLocalSymbols
const __awaiter = require("../util/awaiter")
@@ -79,11 +79,12 @@ export async function createApp(opts: ElectronPackagerOptions, appOutDir: string
})
use(appInfo.buildVersion, it => appPlist.CFBundleVersion = it)
- if (opts.protocols && opts.protocols.length) {
- appPlist.CFBundleURLTypes = opts.protocols.map(function (protocol: any) {
+ const protocols = asArray(opts.platformPackager.devMetadata.build.protocols).concat(asArray(opts.platformPackager.platformSpecificBuildOptions.protocols))
+ if (protocols.length > 0) {
+ appPlist.CFBundleURLTypes = protocols.map(protocol => {
return {
CFBundleURLName: protocol.name,
- CFBundleURLSchemes: [].concat(protocol.schemes)
+ CFBundleURLSchemes: protocol.schemes.slice()
}
})
}
diff --git a/src/targets/nsis.ts b/src/targets/nsis.ts
index 7d74bb0bac8..0fedf9da37a 100644
--- a/src/targets/nsis.ts
+++ b/src/targets/nsis.ts
@@ -1,6 +1,6 @@
import { WinPackager } from "../winPackager"
import { Arch, NsisOptions, FileAssociation } from "../metadata"
-import { exec, debug, doSpawn, handleProcess, use } from "../util/util"
+import { exec, debug, doSpawn, handleProcess, use, asArray } from "../util/util"
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
import { getBinFromBintray } from "../util/binDownload"
@@ -285,16 +285,4 @@ export default class NsisTarget extends Target {
// remove leading dot
function normalizeExt(ext: string) {
return ext.startsWith(".") ? ext.substring(1) : ext
-}
-
-function asArray(v: n | T | Array): Array {
- if (v == null) {
- return []
- }
- else if (Array.isArray(v)) {
- return v
- }
- else {
- return [v]
- }
}
\ No newline at end of file
diff --git a/src/util/util.ts b/src/util/util.ts
index b1d6efd0bff..a7d437d0e20 100644
--- a/src/util/util.ts
+++ b/src/util/util.ts
@@ -274,4 +274,16 @@ export function unlinkIfExists(file: string) {
.catch(() => {
// ignore
})
+}
+
+export function asArray(v: n | T | Array): Array {
+ if (v == null) {
+ return []
+ }
+ else if (Array.isArray(v)) {
+ return v
+ }
+ else {
+ return [v]
+ }
}
\ No newline at end of file