diff --git a/docs/Options.md b/docs/Options.md
index 2686d548590..a4abf4de919 100644
--- a/docs/Options.md
+++ b/docs/Options.md
@@ -62,6 +62,7 @@ Here documented only `electron-builder` specific options:
| linux | See [.build.linux](#LinuxBuildOptions).
| compression | The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly.
| afterPack | *programmatic API only* The function to be run after pack (but before pack into distributable format and sign). Promise must be returned.
+| npmRebuild | Whether to rebuild native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`.
### `.build.osx`
@@ -70,7 +71,7 @@ See all [appdmg options](https://www.npmjs.com/package/appdmg#json-specification
| Name | Description
| --- | ---
-| icon | The path to icon, which will be shown when mounted (default: `build/icon.icns`).
+| icon | The path to DMG icon, which will be shown when mounted. Defaults to `build/icon.icns`.
| background |
The path to background (default: build/background.png
if exists). The resolution of this file determines the resolution of the installer window. If background is not specified, use window.size
, see [specification](https://github.com/LinusU/node-appdmg#json-specification).
| target | Target package type: list of `default`, `dmg`, `mas`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `default` (dmg and zip for Squirrel.Mac).
| identity | The name of certificate to use when signing. Consider using environment variables [CSC_LINK or CSC_NAME](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). MAS installer identity is specified in the [.build.mas](#MasBuildOptions-identity).
diff --git a/src/build-cli.ts b/src/build-cli.ts
index 68ed9c8e235..42005243542 100644
--- a/src/build-cli.ts
+++ b/src/build-cli.ts
@@ -1,67 +1,8 @@
#! /usr/bin/env node
-// import { commonTargets } from "./platformPackager"
import { build, CliOptions } from "./builder"
import { printErrorAndExit } from "./promise"
-import { underline } from "chalk"
-import yargs = require("yargs")
+import { createYargs } from "./cliOptions"
-//noinspection JSUnusedLocalSymbols
-const __awaiter = require("./awaiter")
-
-export function createYargs(): any {
- return yargs
- .version()
- .option("osx", {
- alias: "o",
- describe: "Build for OS X",
- type: "array",
- })
- .option("linux", {
- alias: "l",
- describe: "Build for Linux",
- type: "array",
- })
- .option("win", {
- alias: ["w", "windows"],
- describe: "Build for Windows",
- type: "array",
- })
- .option("x64", {
- describe: "Build for x64",
- type: "boolean",
- })
- .option("ia32", {
- describe: "Build for ia32",
- type: "boolean",
- })
- // .option("target", {
- // alias: "t",
- // describe: "Target package types",
- // choices: commonTargets,
- // })
- .option("publish", {
- alias: "p",
- describe: `Publish artifacts (to GitHub Releases), see ${underline("https://goo.gl/WMlr4n")}`,
- choices: ["onTag", "onTagOrDraft", "always", "never"],
- })
- .option("platform", {
- choices: ["osx", "win", "linux", "darwin", "win32", "all"],
- })
- .option("arch", {
- choices: ["ia32", "x64", "all"],
- })
- .option("npmRebuild", {
- describe: "Runs npm rebuild before starting to package the app.",
- default: true,
- type: "boolean",
- })
- .strict()
- .help()
- .epilog(`Project home: ${underline("https://github.com/electron-userland/electron-builder")}`)
-}
-
-if (!module.parent) {
- build((createYargs().argv))
- .catch(printErrorAndExit)
-}
\ No newline at end of file
+build((createYargs().argv))
+ .catch(printErrorAndExit)
\ No newline at end of file
diff --git a/src/builder.ts b/src/builder.ts
index ef415881993..b58bceacf2c 100644
--- a/src/builder.ts
+++ b/src/builder.ts
@@ -1,10 +1,10 @@
-import { Packager, normalizePlatforms, isEmptyOrSpaces } from "./packager"
+import { Packager, normalizePlatforms } from "./packager"
import { PackagerOptions } from "./platformPackager"
import { PublishOptions, Publisher, GitHubPublisher } from "./gitHubPublisher"
import { executeFinally } from "./promise"
import { Promise as BluebirdPromise } from "bluebird"
import { InfoRetriever } from "./repositoryInfo"
-import { log, warn } from "./util"
+import { log, warn, isEmptyOrSpaces } from "./util"
import { Platform, Arch, archFromString } from "./metadata"
//noinspection JSUnusedLocalSymbols
diff --git a/src/cliOptions.ts b/src/cliOptions.ts
new file mode 100644
index 00000000000..8c2337cf1a1
--- /dev/null
+++ b/src/cliOptions.ts
@@ -0,0 +1,49 @@
+import { underline } from "chalk"
+import yargs = require("yargs")
+
+export function createYargs(): any {
+ return yargs
+ .version()
+ .option("osx", {
+ alias: "o",
+ describe: "Build for OS X",
+ type: "array",
+ })
+ .option("linux", {
+ alias: "l",
+ describe: "Build for Linux",
+ type: "array",
+ })
+ .option("win", {
+ alias: ["w", "windows"],
+ describe: "Build for Windows",
+ type: "array",
+ })
+ .option("x64", {
+ describe: "Build for x64",
+ type: "boolean",
+ })
+ .option("ia32", {
+ describe: "Build for ia32",
+ type: "boolean",
+ })
+ // .option("target", {
+ // alias: "t",
+ // describe: "Target package types",
+ // choices: commonTargets,
+ // })
+ .option("publish", {
+ alias: "p",
+ describe: `Publish artifacts (to GitHub Releases), see ${underline("https://goo.gl/WMlr4n")}`,
+ choices: ["onTag", "onTagOrDraft", "always", "never"],
+ })
+ .option("platform", {
+ choices: ["osx", "win", "linux", "darwin", "win32", "all"],
+ })
+ .option("arch", {
+ choices: ["ia32", "x64", "all"],
+ })
+ .strict()
+ .help()
+ .epilog(`Project home: ${underline("https://github.com/electron-userland/electron-builder")}`)
+}
diff --git a/src/metadata.ts b/src/metadata.ts
index 03d3986327c..80c61611c3f 100755
--- a/src/metadata.ts
+++ b/src/metadata.ts
@@ -151,6 +151,11 @@ export interface BuildMetadata {
*programmatic API only* The function to be run after pack (but before pack into distributable format and sign). Promise must be returned.
*/
readonly afterPack?: (context: AfterPackContext) => Promise | null
+
+ /*
+ Whether to rebuild native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`.
+ */
+ readonly npmRebuild?: boolean
}
export interface AfterPackContext {
@@ -165,7 +170,7 @@ export interface AfterPackContext {
*/
export interface OsXBuildOptions extends PlatformSpecificBuildOptions {
/*
- The path to icon, which will be shown when mounted (default: `build/icon.icns`).
+ The path to DMG icon, which will be shown when mounted. Defaults to `build/icon.icns`.
*/
readonly icon?: string | null
diff --git a/src/osxPackager.ts b/src/osxPackager.ts
index 1d395cc1cee..66a10cae36c 100644
--- a/src/osxPackager.ts
+++ b/src/osxPackager.ts
@@ -2,7 +2,7 @@ import { PlatformPackager, BuildInfo } from "./platformPackager"
import { Platform, OsXBuildOptions, MasBuildOptions, Arch } from "./metadata"
import * as path from "path"
import { Promise as BluebirdPromise } from "bluebird"
-import { log, debug, warn } from "./util"
+import { log, debug, warn, isEmptyOrSpaces } from "./util"
import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName, findIdentity } from "./codeSign"
import deepAssign = require("deep-assign")
import { sign, flat, BaseSignOptions, SignOptions, FlatOptions } from "electron-osx-sign-tf"
@@ -65,7 +65,7 @@ export default class OsXPackager extends PlatformPackager {
private static async findIdentity(certType: string, name?: string | null): Promise {
let identity = process.env.CSC_NAME || name
- if (identity == null || identity.trim().length === 0) {
+ if (isEmptyOrSpaces(identity)) {
return await findIdentity(certType)
}
else {
diff --git a/src/packager.ts b/src/packager.ts
index 093bb5e1fc8..467b5dc0cdd 100644
--- a/src/packager.ts
+++ b/src/packager.ts
@@ -1,7 +1,7 @@
import * as path from "path"
import {
computeDefaultAppDirectory, installDependencies, log, getElectronVersion, readPackageJson, use, warn,
- exec
+ exec, isEmptyOrSpaces
} from "./util"
import { all, executeFinally } from "./promise"
import { EventEmitter } from "events"
@@ -174,7 +174,7 @@ export class Packager implements BuildInfo {
private installAppDependencies(platform: Platform, arch: Arch): Promise {
if (this.isTwoPackageJsonProjectLayoutUsed) {
- if (this.options.npmRebuild === false) {
+ if (this.devMetadata.build.npmRebuild === false) {
log("Skip app dependencies rebuild because npmRebuild is set to false")
}
else if (platform.nodeName === process.platform) {
@@ -247,8 +247,4 @@ async function checkWineVersion(checkPromise: Promise) {
if (compareVersions(wineVersion, "1.8") === -1) {
throw new Error(wineError(`wine 1.8+ is required, but your version is ${wineVersion}`))
}
-}
-
-export function isEmptyOrSpaces(s: string | n) {
- return s == null || s.trim().length === 0
}
\ No newline at end of file
diff --git a/src/platformPackager.ts b/src/platformPackager.ts
index 77915292e22..8ff694fa038 100644
--- a/src/platformPackager.ts
+++ b/src/platformPackager.ts
@@ -50,8 +50,6 @@ export interface PackagerOptions {
* Development `package.json` will be still read, but options specified in this object will override.
*/
readonly devMetadata?: DevMetadata
-
- readonly npmRebuild?: boolean
}
export interface BuildInfo extends ProjectMetadataProvider {
diff --git a/src/util.ts b/src/util.ts
index ba4884b92c4..b917284c858 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -219,4 +219,8 @@ const pidAsString = process.pid.toString(36)
export function getTempName(prefix?: string | n): string {
return `${prefix == null ? "" : prefix + "-"}${pidAsString}-${tmpDirCounter++}-${Date.now().toString(36)}`
+}
+
+export function isEmptyOrSpaces(s: string | n) {
+ return s == null || s.trim().length === 0
}
\ No newline at end of file
diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts
index 1298dabe104..4c66e5e242a 100755
--- a/test/src/BuildTest.ts
+++ b/test/src/BuildTest.ts
@@ -5,12 +5,10 @@ import { move, outputFile, outputJson } from "fs-extra-p"
import { Promise as BluebirdPromise } from "bluebird"
import * as path from "path"
import { assertThat } from "./helpers/fileAssert"
-import { Platform, Arch, PackagerOptions, DIR_TARGET, createTargets } from "out"
+import { archFromString, BuildOptions, Platform, Arch, PackagerOptions, DIR_TARGET, createTargets } from "out"
import pathSorter = require("path-sort")
import { normalizeOptions } from "out/builder"
-import { createYargs } from "out/build-cli"
-import { BuildOptions } from "out/builder"
-import { archFromString } from "out/metadata"
+import { createYargs } from "out/cliOptions"
//noinspection JSUnusedLocalSymbols
const __awaiter = require("out/awaiter")
@@ -20,7 +18,6 @@ test("cli", (t) => {
const base = {
publish: undefined,
- npmRebuild: true,
}
function expected(opt: PackagerOptions): any {
diff --git a/test/src/helpers/avaEx.ts b/test/src/helpers/avaEx.ts
index 8fa7aa12508..71dbc711292 100644
--- a/test/src/helpers/avaEx.ts
+++ b/test/src/helpers/avaEx.ts
@@ -45,7 +45,6 @@ Object.defineProperties(test, {
},
"ifDevOrWinCi": {
get: function () {
- console.log(process.env)
return process.env.CI == null || process.platform === "win32" ? this : this.skip
}
},
diff --git a/tsconfig.json b/tsconfig.json
index f19d3e04fa9..a6fdccdbd77 100755
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -59,6 +59,7 @@
"src/build-cli.ts",
"src/builder.ts",
"src/cleanup.ts",
+ "src/cliOptions.ts",
"src/codeSign.ts",
"src/errorMessages.ts",
"src/fpmDownload.ts",