Skip to content

Commit

Permalink
fix: coerce mac.identity from "null" to null
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jul 10, 2017
1 parent 4af210e commit 791b94b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"json5": "^0.5.1",
"mime": "^1.3.6",
"minimatch": "^3.0.4",
"node-emoji": "^1.6.1",
"node-emoji": "^1.7.0",
"normalize-package-data": "^2.4.0",
"parse-color": "^1.0.0",
"plist": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"bluebird-lst": "^1.0.2",
"chalk": "^2.0.1",
"debug": "^2.6.8",
"node-emoji": "^1.6.1",
"node-emoji": "^1.7.0",
"electron-builder-http": "~0.0.0-semantic-release",
"source-map-support": "^0.4.15",
"7zip-bin": "^2.1.0",
Expand Down
46 changes: 28 additions & 18 deletions packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,32 +169,42 @@ export function normalizeOptions(args: CliOptions): BuildOptions {
(config as any).extraMetadata = extraMetadata
}

if (config != null && typeof config !== "string" && config.extraMetadata != null) {
coerceTypes(config.extraMetadata)
if (config != null && typeof config !== "string") {
if (config.extraMetadata != null) {
coerceTypes(config.extraMetadata)
}
if (config.mac != null) {
// ability to disable code sign using -c.mac.identity=null
coerceValue(config.mac, "identity")
}
}

return result as BuildOptions
}

function coerceValue(host: any, key: string): void {
const value = host[key]
if (value === "true") {
host[key] = true
}
else if (value === "false") {
host[key] = false
}
else if (value === "null") {
host[key] = null
}
else if (key === "version" && typeof value === "number") {
host[key] = value.toString()
}
else if (value != null && typeof value === "object") {
coerceTypes(value)
}
}

/** @private */
export function coerceTypes(host: any): any {
for (const key of Object.getOwnPropertyNames(host)) {
const value = host[key]
if (value === "true") {
host[key] = true
}
else if (value === "false") {
host[key] = false
}
else if (value === "null") {
host[key] = null
}
else if (key === "version" && typeof value === "number") {
host[key] = value.toString()
}
else if (value != null && typeof value === "object") {
coerceTypes(value)
}
coerceValue(host, key)
}
return host
}
Expand Down
23 changes: 14 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.5.31.tgz#54aeb8bcaaf94a7b1a64311bc318dbfe601a593a"

"@types/node@*":
version "8.0.9"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.9.tgz#19f44c3b6cb8a70d261d366f73650e3e3891ab2d"
version "8.0.10"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.10.tgz#12efec9183b072d5f951cf86395a4c780f868a17"

"@types/source-map-support@^0.4.0":
version "0.4.0"
Expand Down Expand Up @@ -2234,6 +2234,10 @@ lodash.pick@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"

lodash.toarray@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561"

lodash@^4.0.0, lodash@^4.14.0, lodash@^4.2.0, lodash@^4.5.1, lodash@^4.8.0:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
Expand Down Expand Up @@ -2391,10 +2395,11 @@ natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"

node-emoji@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.6.1.tgz#7d2f0a8fd11237cba0ddcef3bdc015dc50b011f9"
node-emoji@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.7.0.tgz#a400490aac409b616d13941532200f128af037f9"
dependencies:
lodash.toarray "^4.4.0"
string.prototype.codepointat "^0.2.0"

node-int64@^0.4.0:
Expand Down Expand Up @@ -2875,7 +2880,7 @@ repeating@^2.0.0:
dependencies:
is-finite "^1.0.0"

req-then@^0.6.2:
req-then@^0.6.4:
version "0.6.4"
resolved "https://registry.yarnpkg.com/req-then/-/req-then-0.6.4.tgz#9f9c04626afd311ae01d727846a0a1075c0e1965"
dependencies:
Expand Down Expand Up @@ -3499,13 +3504,13 @@ [email protected]:
querystring "0.2.0"

usage-stats@^0.9.0:
version "0.9.3"
resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.9.3.tgz#6c906491becb9b4e8659f2e0d27f337fcf8f087e"
version "0.9.4"
resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.9.4.tgz#ff06ba51d824faa1982f48a055dea8495a249077"
dependencies:
array-back "^2.0.0"
home-path "^1.0.5"
mkdirp2 "^1.0.3"
req-then "^0.6.2"
req-then "^0.6.4"
typical "^2.6.1"
uuid "^3.1.0"

Expand Down

0 comments on commit 791b94b

Please sign in to comment.