Skip to content

Commit

Permalink
Do not restrict platform options when building installers
Browse files Browse the repository at this point in the history
Allow all options to be passed and let elctron-builder to fail if needed
Fixes #14
  • Loading branch information
wojtkowiak committed Nov 16, 2016
1 parent 6fd7177 commit 1cfe6eb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
10 changes: 7 additions & 3 deletions lib/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ program
'of .desktop, packs app to app.asar')
.option('-a, --android', 'force adding android as a mobile platform instead of ios')
.option('-s, --scaffold', 'will scaffold .desktop if not present')
.option('--ia32', 'generate 32bit installer')
.option('--win', 'generate also a Windows installer on Mac');
.option('--ia32', 'generate 32bit installer/package')
.option('--all-archs', 'generate 32bit and 64bit installers')
.option('--win', 'generate Windows installer')
.option('--linux', 'generate Linux installer')
.option('--mac', 'generate Mac installer');

program
.usage('[command] [options]')
Expand Down Expand Up @@ -91,7 +94,8 @@ function verifyArgsSyntax() {
let npmArgv;
try {
const args = ['-b', '--build-meteor', '-t', '--build-timeout', '-p', '--port',
'--production', '-a', '--android', '-s', '--scaffold', '--ia32', '--win'];
'--production', '-a', '--android', '-s', '--scaffold', '--ia32', '--win',
'--linux', '--all-archs', '--no-current-platform'];
npmArgv = JSON.parse(process.env.npm_config_argv);
if (npmArgv.remain.length === 0 && npmArgv.original.length > 2) {
if (npmArgv.original.some(arg => !!~args.indexOf(arg))) {
Expand Down
35 changes: 24 additions & 11 deletions lib/installerBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,36 @@ export default class InstallerBuilder {
// We are handling asar'ing and rebuilding in the normal run/build flow so we do not
// want electron-rebuild to do that.
settings.builderOptions.asar = false;
settings.builderOptions.npmRebuild = false;
settings.builderOptions.npmRebuild = true;

const arch = this.$.env.options.ia32 ? 'ia32' : 'x64';
let arch = this.$.env.options.ia32 ? 'ia32' : 'x64';

let target;
if (this.$.env.os.isWindows) {
target = createTargets([Platform.WINDOWS], null, arch);
} else if (this.$.env.os.isLinux) {
target = createTargets([Platform.LINUX], null, arch);
} else {
const targets = [Platform.OSX];
if (this.$.env.options.win) {
arch = this.$.env.options.allArchs ? 'all' : arch;

const targets = [];

if (this.$.env.options.win) {
targets.push(Platform.WINDOWS);
}
if (this.$.env.options.linux) {
targets.push(Platform.LINUX);
}
if (this.$.env.options.mac) {
targets.push(Platform.MAC);
}

if (targets.length === 0) {
if (this.$.env.os.isWindows) {
targets.push(Platform.WINDOWS);
} else if (this.$.env.os.isLinux) {
targets.push(Platform.LINUX);
} else {
targets.push(Platform.MAC);
}
target = createTargets(targets, null, arch);
}

const target = createTargets(targets, null, arch);

try {
await build({
targets: target,
Expand Down

0 comments on commit 1cfe6eb

Please sign in to comment.