diff --git a/.gitignore b/.gitignore
index 6cd89979bf8..8f131770e95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,16 +1,31 @@
node_modules/
*.log
-out/
+
+#**/out/**/*
+#!**/*js.snap
+
dist/
+
/.idea/compiler.xml
/.idea/encodings.xml
-/.idea/copyright/profiles_settings.xml
/.idea/workspace.xml
+/.idea/copyright/
/.idea/deployment.xml
+/.idea/shelf/
+
+/docs/.idea/
+
/typings/browser/
/typings/browser.d.ts
/typings/main.d.ts
+
.DS_Store
-.idea/shelf/
+
/test/typings/electron-builder.d.ts
-/test/typings/electron-auto-updater.d.ts
\ No newline at end of file
+/test/typings/electron-auto-updater.d.ts
+
+/nsis-auto-updater/out/
+/out/
+# to not exclude .js.snap (jest snapshots)
+/test/out/**/*.js
+/test/out/**/*.map
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index a4ab52713ac..3d4082833f6 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -3,8 +3,13 @@
+
+
+
+
+
diff --git a/package.json b/package.json
index e2dc77bc5ae..f0cf88588be 100644
--- a/package.json
+++ b/package.json
@@ -99,7 +99,7 @@
"devDependencies": {
"@develar/semantic-release": "^6.3.24",
"@types/ini": "^1.3.29",
- "@types/jest": "^16.0.0",
+ "@types/jest": "^16.0.1",
"@types/js-yaml": "^3.5.28",
"@types/source-map-support": "^0.2.28",
"babel-plugin-array-includes": "^2.0.3",
@@ -115,7 +115,7 @@
"jest-cli": "^17.0.3",
"json8": "^0.9.2",
"path-sort": "^0.1.0",
- "ts-babel": "^1.1.5",
+ "ts-babel": "^1.2.2",
"tslint": "^4.0.2",
"typescript": "^2.1.1",
"validate-commit-msg": "^2.8.2",
diff --git a/src/packager/mac.ts b/src/packager/mac.ts
index db825ebeb17..8ce289bc0ad 100644
--- a/src/packager/mac.ts
+++ b/src/packager/mac.ts
@@ -5,7 +5,7 @@ import BluebirdPromise from "bluebird-lst-c"
import { use, asArray } from "../util/util"
import { normalizeExt, PlatformPackager } from "../platformPackager"
import { warn } from "../util/log"
-import { unlinkIfExists } from "../util/fs"
+import { unlinkIfExists, copyFile } from "../util/fs"
function doRename (basePath: string, oldName: string, newName: string) {
return rename(path.join(basePath, oldName), path.join(basePath, newName))
@@ -98,17 +98,25 @@ export async function createApp(packager: PlatformPackager, appOutDir: stri
})
}
+ const resourcesPath = path.join(contentsPath, "Resources")
+
const fileAssociations = packager.getFileAssociations()
if (fileAssociations.length > 0) {
appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
const extensions = asArray(fileAssociation.ext).map(normalizeExt)
const customIcon = await packager.getResource(fileAssociation.icon, `${extensions[0]}.icns`)
+ let iconFile = appPlist.CFBundleIconFile
+ if (customIcon != null) {
+ iconFile = path.basename(customIcon)
+ await copyFile(customIcon, path.join(resourcesPath, iconFile))
+ }
+
// todo rename electron.icns
return {
CFBundleTypeExtensions: extensions,
CFBundleTypeName: fileAssociation.name,
CFBundleTypeRole: fileAssociation.role || "Editor",
- CFBundleTypeIconFile: customIcon || appPlist.CFBundleIconFile
+ CFBundleTypeIconFile: iconFile
}
})
}
@@ -127,8 +135,8 @@ export async function createApp(packager: PlatformPackager, appOutDir: stri
]
if (icon != null) {
- promises.push(unlink(path.join(contentsPath, "Resources", oldIcon)))
- promises.push(copy(icon, path.join(contentsPath, "Resources", appPlist.CFBundleIconFile)))
+ promises.push(unlink(path.join(resourcesPath, oldIcon)))
+ promises.push(copy(icon, path.join(resourcesPath, appPlist.CFBundleIconFile)))
}
await BluebirdPromise.all(promises)
diff --git a/test/out/mac/__snapshots__/macPackagerTest.js.snap b/test/out/mac/__snapshots__/macPackagerTest.js.snap
new file mode 100644
index 00000000000..bbe30f639e4
--- /dev/null
+++ b/test/out/mac/__snapshots__/macPackagerTest.js.snap
@@ -0,0 +1,35 @@
+exports[`test one-package 1`] = `
+Object {
+ "BuildMachineOSBuild": "15E65",
+ "CFBundleDisplayName": "Test App ß/W",
+ "CFBundleDocumentTypes": Array [
+ Object {
+ "CFBundleTypeExtensions": Array [
+ "foo",
+ ],
+ "CFBundleTypeIconFile": "foo.icns",
+ "CFBundleTypeName": "Foo",
+ "CFBundleTypeRole": "Viewer",
+ },
+ ],
+ "CFBundleExecutable": "Test App ßW",
+ "CFBundleIconFile": "Test App ßW.icns",
+ "CFBundleIdentifier": "org.electron-builder.testApp",
+ "CFBundleInfoDictionaryVersion": "6.0",
+ "CFBundleName": "Test App ß/W",
+ "CFBundlePackageType": "APPL",
+ "CFBundleShortVersionString": "1.1.0",
+ "CFBundleVersion": "1.1.0.42",
+ "DTSDKBuild": "14D125",
+ "DTSDKName": "macosx10.1010.10",
+ "DTXcode": "0721",
+ "DTXcodeBuild": "7C1002",
+ "LSApplicationCategoryType": "your.app.category.type",
+ "LSMinimumSystemVersion": "10.9.0",
+ "NSHighResolutionCapable": true,
+ "NSHumanReadableCopyright": "Copyright © 2016 Foo Bar",
+ "NSMainNibFile": "MainMenu",
+ "NSPrincipalClass": "AtomApplication",
+ "NSSupportsAutomaticGraphicsSwitching": true,
+}
+`;
diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts
index d83c398d1ff..27a3f8f416a 100755
--- a/test/src/helpers/packTester.ts
+++ b/test/src/helpers/packTester.ts
@@ -34,6 +34,7 @@ interface AssertPackOptions {
readonly expectedArtifacts?: Array
readonly expectedDepends?: string
+ readonly checkMacApp?: (appDir: string, info: any) => Promise
readonly useTempDir?: boolean
readonly signed?: boolean
@@ -184,7 +185,7 @@ async function packAndCheck(outDir: string, packagerOptions: PackagerOptions, ch
const nameToTarget = platformToTarget.get(platform)
if (platform === Platform.MAC) {
- await checkOsXResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.MAC))
+ await checkMacResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.MAC))
}
else if (platform === Platform.LINUX) {
await checkLinuxResult(outDir, packager, checkOptions, artifacts.get(Platform.LINUX), arch, nameToTarget)
@@ -273,7 +274,7 @@ function parseDebControl(info: string): any {
return metadata
}
-async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array) {
+async function checkMacResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array) {
const appInfo = packager.appInfo
const packedAppDir = path.join(path.dirname(artifacts[0].file), `${appInfo.productFilename}.app`)
const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8"))
@@ -284,6 +285,10 @@ async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptio
CFBundleVersion: `${appInfo.version}.${(process.env.TRAVIS_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM)}`
})
+ if (checkOptions.checkMacApp != null) {
+ await checkOptions.checkMacApp(packedAppDir, info)
+ }
+
if (packagerOptions.cscLink != null) {
const result = await exec("codesign", ["--verify", packedAppDir])
expect(result).not.toMatch(/is not signed at all/)
diff --git a/test/src/mac/macPackagerTest.ts b/test/src/mac/macPackagerTest.ts
index bcbd6a26357..adee8321e72 100644
--- a/test/src/mac/macPackagerTest.ts
+++ b/test/src/mac/macPackagerTest.ts
@@ -1,13 +1,38 @@
import { assertPack, platform, modifyPackageJson, app, appThrows } from "../helpers/packTester"
import { Platform, createTargets } from "out"
import { DIR_TARGET } from "out/targets/targetFactory"
+import { copyFile } from "out/util/fs"
+import * as path from "path"
+import { assertThat } from "../helpers/fileAssert"
test.ifMac("two-package", () => assertPack("test-app", {targets: createTargets([Platform.MAC], null, "all")}, {signed: true, useTempDir: true}))
-test.ifMac("one-package", app(platform(Platform.MAC), {signed: true}))
+test.ifMac("one-package", app({
+ targets: Platform.MAC.createTarget(),
+ devMetadata: {
+ build: {
+ mac: {
+ fileAssociations: [
+ {
+ ext: "foo",
+ name: "Foo",
+ role: "Viewer",
+ },
+ ]
+ }
+ }
+ }
+}, {
+ signed: true,
+ projectDirCreated: projectDir => copyFile(path.join(projectDir, "build", "icon.icns"), path.join(projectDir, "build", "foo.icns")),
+ checkMacApp: async (appDir, info) => {
+ expect(info).toMatchSnapshot()
+ await assertThat(path.join(appDir, "Contents", "Resources", "foo.icns")).isFile()
+ },
+}))
test.ifMac("electronDist", appThrows(/ENOENT: no such file or directory/, {
- targets: Platform.OSX.createTarget(DIR_TARGET),
+ targets: Platform.MAC.createTarget(DIR_TARGET),
}, {
projectDirCreated: projectDir => modifyPackageJson(projectDir, data => {
data.build.electronDist = "foo"
diff --git a/yarn.lock b/yarn.lock
index 2e97672a01b..3448cf12318 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -58,9 +58,9 @@
version "1.3.29"
resolved "https://registry.yarnpkg.com/@types/ini/-/ini-1.3.29.tgz#1325e981e047d40d13ce0359b821475b97741d2f"
-"@types/jest@^16.0.0":
- version "16.0.0"
- resolved "https://registry.yarnpkg.com/@types/jest/-/jest-16.0.0.tgz#5fe49adee6db194357a52438c0d80695b59a45e9"
+"@types/jest@^16.0.1":
+ version "16.0.1"
+ resolved "https://registry.yarnpkg.com/@types/jest/-/jest-16.0.1.tgz#c7820ab2bedefe121d0e5ffaa8d0b22f44793f24"
"@types/js-yaml@^3.5.28":
version "3.5.28"
@@ -2435,9 +2435,9 @@ map-stream@~0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194"
-markdown-it@^8.1.0:
- version "8.1.0"
- resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.1.0.tgz#38902d4e7bac2260c073eb67be623211fbb2c2e3"
+markdown-it@^8.2.0:
+ version "8.2.0"
+ resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.2.0.tgz#089e924bc2efd3886a2eb8ab869109c5ceb73958"
dependencies:
argparse "^1.0.7"
entities "~1.1.1"
@@ -3485,15 +3485,15 @@ truncate-utf8-bytes@^1.0.0:
dependencies:
utf8-byte-length "^1.0.1"
-ts-babel@^1.1.5:
- version "1.1.5"
- resolved "https://registry.yarnpkg.com/ts-babel/-/ts-babel-1.1.5.tgz#5a83460bb66eeb6c5af727ad18afb4f3c6e189b8"
+ts-babel@^1.2.2:
+ version "1.2.2"
+ resolved "https://registry.yarnpkg.com/ts-babel/-/ts-babel-1.2.2.tgz#d2e315c9202924b4979adcf56c047aa7ba1e002d"
dependencies:
babel-core "^6.18.2"
bluebird-lst-c "^1.0.5"
chalk "^1.1.3"
- fs-extra-p "^3.0.2"
- markdown-it "^8.1.0"
+ fs-extra-p "^3.0.3"
+ markdown-it "^8.2.0"
source-map-support "^0.4.6"
tslint@^4.0.2: