Skip to content

Commit

Permalink
fix: add debug log to investigate "Cannot build app with 3.6.2+" #360
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Apr 28, 2016
1 parent fd7201e commit 1970550
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"bluebird": "^3.3.5",
"chalk": "^1.1.3",
"command-line-args": "^2.1.6",
"debug": "^2.2.0",
"deep-assign": "^2.0.0",
"electron-osx-sign-tf": "^0.4.0-beta.0",
"electron-packager-tf": "^7.0.2-beta.0",
Expand Down
6 changes: 3 additions & 3 deletions src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PlatformPackager, BuildInfo } from "./platformPackager"
import { Platform, OsXBuildOptions } from "./metadata"
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
import { log, spawn, statOrNull } from "./util"
import { log, debug, spawn, statOrNull } from "./util"
import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName } from "./codeSign"
import { path7za } from "7zip-bin"
import deepAssign = require("deep-assign")
Expand Down Expand Up @@ -162,7 +162,7 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {
log("Creating ZIP for Squirrel.Mac")
// we use app name here - see https://github.com/electron-userland/electron-builder/pull/204
const resultPath = `${this.appName}-${this.metadata.version}-mac.zip`
const args = ["a", "-mm=" + (this.devMetadata.build.compression === "store" ? "Copy" : "Deflate"), "-bb0", "-bd"]
const args = ["a", "-mm=" + (this.devMetadata.build.compression === "store" ? "Copy" : "Deflate"), "-bb" + (debug.enabled ? "3" : "0"), "-bd"]
if (this.devMetadata.build.compression === "maximum") {
// http://superuser.com/a/742034
//noinspection SpellCheckingInspection
Expand All @@ -172,7 +172,7 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {

return spawn(path7za, args, {
cwd: outDir,
stdio: ["ignore", "ignore", "inherit"],
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
})
.thenReturn(path.join(outDir, resultPath))
}
Expand Down
12 changes: 12 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import * as os from "os"
import * as path from "path"
import { readJson, stat } from "fs-extra-p"
import { yellow } from "chalk"
import debugFactory = require("debug")
import { Debugger } from "~debug/node"

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

export const log = console.log

export const debug: Debugger = debugFactory("electron-builder")

export function warn(message: string) {
console.warn(yellow(message))
}
Expand Down Expand Up @@ -68,6 +72,10 @@ export interface SpawnOptions extends BaseExecOptions {
}

export function exec(file: string, args?: string[], options?: ExecOptions): BluebirdPromise<Buffer[]> {
if (debug.enabled) {
debug(`Executing ${file} ${args.join(" ")}`)
}

return new BluebirdPromise<Buffer[]>((resolve, reject) => {
execFile(file, args, options, function (error, stdout, stderr) {
if (error == null) {
Expand All @@ -89,6 +97,10 @@ export function exec(file: string, args?: string[], options?: ExecOptions): Blue
}

export function spawn(command: string, args?: string[], options?: SpawnOptions): BluebirdPromise<any> {
if (debug.enabled) {
debug(`Spawning ${command} ${args.join(" ")}`)
}

return new BluebirdPromise<any>((resolve, reject) => {
const p = _spawn(command, args, options)
p.on("close", (code: number) => code === 0 ? resolve() : reject(new Error(command + " exited with code " + code)))
Expand Down
1 change: 1 addition & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"../typings/main/ambient/progress/progress.d.ts",
"../typings/main/ambient/tmp/tmp.d.ts",
"../typings/main/definitions/chalk/index.d.ts",
"../typings/main/definitions/debug/index.d.ts",
"../typings/main/definitions/source-map-support/source-map-support.d.ts",
"../typings/node.d.ts",
"../typings/progress-stream.d.ts",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"typings/main/ambient/progress/progress.d.ts",
"typings/main/ambient/tmp/tmp.d.ts",
"typings/main/definitions/chalk/index.d.ts",
"typings/main/definitions/debug/index.d.ts",
"typings/main/definitions/source-map-support/source-map-support.d.ts",
"typings/node.d.ts",
"typings/progress-stream.d.ts",
Expand Down
58 changes: 58 additions & 0 deletions typings/main/definitions/debug/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-ms/f40c81c7f45bc35e970de851117c29fc959220b2/index.d.ts
declare module '~debug~ms/index' {
function ms (value: string): number;
function ms (value: number, options?: ms.Options): string;

module ms {
export interface Options {
long: boolean;
}
}

export = ms;
}
declare module '~debug~ms' {
import main = require('~debug~ms/index');
export = main;
}

// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-debug/0e398cb21de268744dd048a11461be5c13230bad/node.d.ts
declare module '~debug/node' {
import ms = require('~debug~ms');

function debug (namespace: string): debug.Debugger;

module debug {
export interface Debugger {
(message: any, ...args: any[]): void;
enabled: boolean;
namespace: string;
}

export function coerce (value: any): any;
export function disable (): void;
export function enable (namespaces: string): void;
export function enabled (namespace: string): boolean;
export var humanize: typeof ms;

// Node implementation exports.
export var log: Function;
export function formatArgs (...args: any[]): any;
export function save (namespaces?: string): void;
export function load (): string | void;
export function useColors (): boolean;
export var colors: number[];
}

export = debug;
}
declare module 'debug/node' {
import main = require('~debug/node');
export = main;
}
declare module 'debug' {
import main = require('~debug/node');
export = main;
}

0 comments on commit 1970550

Please sign in to comment.