Skip to content

Commit 1970550

Browse files
committed
fix: add debug log to investigate "Cannot build app with 3.6.2+" #360
1 parent fd7201e commit 1970550

File tree

6 files changed

+76
-3
lines changed

6 files changed

+76
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"bluebird": "^3.3.5",
5959
"chalk": "^1.1.3",
6060
"command-line-args": "^2.1.6",
61+
"debug": "^2.2.0",
6162
"deep-assign": "^2.0.0",
6263
"electron-osx-sign-tf": "^0.4.0-beta.0",
6364
"electron-packager-tf": "^7.0.2-beta.0",

src/macPackager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { PlatformPackager, BuildInfo } from "./platformPackager"
22
import { Platform, OsXBuildOptions } from "./metadata"
33
import * as path from "path"
44
import { Promise as BluebirdPromise } from "bluebird"
5-
import { log, spawn, statOrNull } from "./util"
5+
import { log, debug, spawn, statOrNull } from "./util"
66
import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName } from "./codeSign"
77
import { path7za } from "7zip-bin"
88
import deepAssign = require("deep-assign")
@@ -162,7 +162,7 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {
162162
log("Creating ZIP for Squirrel.Mac")
163163
// we use app name here - see https://github.com/electron-userland/electron-builder/pull/204
164164
const resultPath = `${this.appName}-${this.metadata.version}-mac.zip`
165-
const args = ["a", "-mm=" + (this.devMetadata.build.compression === "store" ? "Copy" : "Deflate"), "-bb0", "-bd"]
165+
const args = ["a", "-mm=" + (this.devMetadata.build.compression === "store" ? "Copy" : "Deflate"), "-bb" + (debug.enabled ? "3" : "0"), "-bd"]
166166
if (this.devMetadata.build.compression === "maximum") {
167167
// http://superuser.com/a/742034
168168
//noinspection SpellCheckingInspection
@@ -172,7 +172,7 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {
172172

173173
return spawn(path7za, args, {
174174
cwd: outDir,
175-
stdio: ["ignore", "ignore", "inherit"],
175+
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
176176
})
177177
.thenReturn(path.join(outDir, resultPath))
178178
}

src/util.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ import * as os from "os"
55
import * as path from "path"
66
import { readJson, stat } from "fs-extra-p"
77
import { yellow } from "chalk"
8+
import debugFactory = require("debug")
9+
import { Debugger } from "~debug/node"
810

911
//noinspection JSUnusedLocalSymbols
1012
const __awaiter = require("./awaiter")
1113

1214
export const log = console.log
1315

16+
export const debug: Debugger = debugFactory("electron-builder")
17+
1418
export function warn(message: string) {
1519
console.warn(yellow(message))
1620
}
@@ -68,6 +72,10 @@ export interface SpawnOptions extends BaseExecOptions {
6872
}
6973

7074
export function exec(file: string, args?: string[], options?: ExecOptions): BluebirdPromise<Buffer[]> {
75+
if (debug.enabled) {
76+
debug(`Executing ${file} ${args.join(" ")}`)
77+
}
78+
7179
return new BluebirdPromise<Buffer[]>((resolve, reject) => {
7280
execFile(file, args, options, function (error, stdout, stderr) {
7381
if (error == null) {
@@ -89,6 +97,10 @@ export function exec(file: string, args?: string[], options?: ExecOptions): Blue
8997
}
9098

9199
export function spawn(command: string, args?: string[], options?: SpawnOptions): BluebirdPromise<any> {
100+
if (debug.enabled) {
101+
debug(`Spawning ${command} ${args.join(" ")}`)
102+
}
103+
92104
return new BluebirdPromise<any>((resolve, reject) => {
93105
const p = _spawn(command, args, options)
94106
p.on("close", (code: number) => code === 0 ? resolve() : reject(new Error(command + " exited with code " + code)))

test/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"../typings/main/ambient/progress/progress.d.ts",
4040
"../typings/main/ambient/tmp/tmp.d.ts",
4141
"../typings/main/definitions/chalk/index.d.ts",
42+
"../typings/main/definitions/debug/index.d.ts",
4243
"../typings/main/definitions/source-map-support/source-map-support.d.ts",
4344
"../typings/node.d.ts",
4445
"../typings/progress-stream.d.ts",

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"typings/main/ambient/progress/progress.d.ts",
4545
"typings/main/ambient/tmp/tmp.d.ts",
4646
"typings/main/definitions/chalk/index.d.ts",
47+
"typings/main/definitions/debug/index.d.ts",
4748
"typings/main/definitions/source-map-support/source-map-support.d.ts",
4849
"typings/node.d.ts",
4950
"typings/progress-stream.d.ts",
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Generated by typings
2+
// Source: https://raw.githubusercontent.com/typed-typings/npm-ms/f40c81c7f45bc35e970de851117c29fc959220b2/index.d.ts
3+
declare module '~debug~ms/index' {
4+
function ms (value: string): number;
5+
function ms (value: number, options?: ms.Options): string;
6+
7+
module ms {
8+
export interface Options {
9+
long: boolean;
10+
}
11+
}
12+
13+
export = ms;
14+
}
15+
declare module '~debug~ms' {
16+
import main = require('~debug~ms/index');
17+
export = main;
18+
}
19+
20+
// Generated by typings
21+
// Source: https://raw.githubusercontent.com/typed-typings/npm-debug/0e398cb21de268744dd048a11461be5c13230bad/node.d.ts
22+
declare module '~debug/node' {
23+
import ms = require('~debug~ms');
24+
25+
function debug (namespace: string): debug.Debugger;
26+
27+
module debug {
28+
export interface Debugger {
29+
(message: any, ...args: any[]): void;
30+
enabled: boolean;
31+
namespace: string;
32+
}
33+
34+
export function coerce (value: any): any;
35+
export function disable (): void;
36+
export function enable (namespaces: string): void;
37+
export function enabled (namespace: string): boolean;
38+
export var humanize: typeof ms;
39+
40+
// Node implementation exports.
41+
export var log: Function;
42+
export function formatArgs (...args: any[]): any;
43+
export function save (namespaces?: string): void;
44+
export function load (): string | void;
45+
export function useColors (): boolean;
46+
export var colors: number[];
47+
}
48+
49+
export = debug;
50+
}
51+
declare module 'debug/node' {
52+
import main = require('~debug/node');
53+
export = main;
54+
}
55+
declare module 'debug' {
56+
import main = require('~debug/node');
57+
export = main;
58+
}

0 commit comments

Comments
 (0)