Skip to content

Commit

Permalink
fix(mac): build mac targets on non-macOs
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Sep 1, 2016
1 parent 91addfe commit 1398af4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@
"dependencies": {
"7zip-bin": "^1.0.6",
"ansi-escapes": "^1.4.0",
"archiver": "^1.0.1",
"archiver": "^1.1.0",
"archiver-utils": "^1.3.0",
"asar-electron-builder": "^0.13.2",
"bluebird": "^3.4.3",
"asar-electron-builder": "^0.13.5",
"bluebird": "^3.4.5",
"chalk": "^1.1.3",
"chromium-pickle-js": "^0.1.0",
"chromium-pickle-js": "^0.2.0",
"cli-cursor": "^1.0.2",
"cuint": "^0.2.2",
"debug": "^2.2.0",
Expand Down Expand Up @@ -123,7 +123,7 @@
"pre-git": "^3.10.0",
"ts-babel": "^1.0.4",
"tslint": "^3.15.1",
"typescript": "^2.1.0-dev.20160826",
"typescript": "^2.0.2",
"whitespace": "^2.1.0"
},
"babel": {
Expand Down
6 changes: 5 additions & 1 deletion src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
constructor(info: BuildInfo) {
super(info)

if (this.options.cscLink == null) {
if (this.options.cscLink == null || process.platform !== "darwin") {
this.codeSigningInfo = BluebirdPromise.resolve({})
}
else {
Expand Down Expand Up @@ -96,6 +96,10 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
}

private async sign(appOutDir: string, masOptions: MasBuildOptions | null): Promise<void> {
if (process.platform !== "darwin") {
return
}

let keychainName = (await this.codeSigningInfo).keychainName
const masQualifier = masOptions == null ? null : (masOptions.identity || this.platformSpecificBuildOptions.identity)

Expand Down
3 changes: 1 addition & 2 deletions src/targets/dmg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Target, PlatformPackager } from "../platformPackager"
import { MacOptions, DmgOptions } from "../metadata"
import { Promise as BluebirdPromise } from "bluebird"
import { debug, use } from "../util/util"
import appdmg = require("appdmg")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../util/awaiter")
Expand Down Expand Up @@ -46,7 +45,7 @@ export class DmgTarget extends Target {
debug(`appdmg: ${JSON.stringify(dmgOptions, <any>null, 2)}`)
}

const emitter = appdmg(dmgOptions)
const emitter = require("appdmg")(dmgOptions)
emitter.on("error", reject)
emitter.on("finish", () => resolve())
if (debug.enabled) {
Expand Down
3 changes: 1 addition & 2 deletions test/src/helpers/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ function runTests(): BluebirdPromise<any> {
args.push(path.join(baseDir, "linuxPackagerTest.js"), path.join(baseDir, "BuildTest.js"), path.join(baseDir, "globTest.js"))
}
else {
args.push(path.join(baseDir, "winPackagerTest.js"))
args.push(path.join(baseDir, "nsisTest.js"))
args.push(path.join(baseDir, "winPackagerTest.js"), path.join(baseDir, "nsisTest.js"), path.join(baseDir, "macPackagerTest.js"))
args.push(...baseForLinuxTests)
}
console.log(`Test files for node ${circleNodeIndex}: ${args.join(", ")}`)
Expand Down
15 changes: 5 additions & 10 deletions test/src/macPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { assertPack, platform, modifyPackageJson, signed, app } from "./helpers/
import OsXPackager from "out/macPackager"
import { move, writeFile, deleteFile, remove } from "fs-extra-p"
import * as path from "path"
import { BuildInfo, PackagerOptions } from "out/platformPackager"
import { BuildInfo } from "out/platformPackager"
import { Promise as BluebirdPromise } from "bluebird"
import { assertThat } from "./helpers/fileAssert"
import { ElectronPackagerOptions } from "out/packager/dirPackager"
Expand All @@ -21,7 +21,7 @@ test.ifOsx("two-package", () => assertPack("test-app", {targets: createTargets([
test.ifOsx("one-package", app(platform(Platform.MAC), {signed: true}))

function createTargetTest(target: Array<string>, expectedContents: Array<string>) {
let options: PackagerOptions = {
return app({
targets: Platform.MAC.createTarget(),
devMetadata: {
build: {
Expand All @@ -30,19 +30,14 @@ function createTargetTest(target: Array<string>, expectedContents: Array<string>
}
}
}
}
if (target.includes("mas")) {
options = signed(options)
}

return app(options, {expectedContents: expectedContents})
}, {expectedContents: expectedContents, signed: target.includes("mas")})
}

test.ifOsx("only dmg", createTargetTest(["dmg"], ["Test App ßW-1.1.0.dmg"]))
test.ifOsx("only zip", createTargetTest(["zip"], ["Test App ßW-1.1.0-mac.zip"]))
test("only zip", createTargetTest(["zip"], ["Test App ßW-1.1.0-mac.zip"]))
test.ifOsx("invalid target", t => t.throws(createTargetTest(["ttt"], [])(), "Unknown target: ttt"))

if (process.env.CSC_KEY_PASSWORD == null) {
if (process.env.CSC_KEY_PASSWORD == null || process.platform !== "darwin") {
console.warn("Skip mas tests because CSC_KEY_PASSWORD is not defined")
}
else {
Expand Down

0 comments on commit 1398af4

Please sign in to comment.