Skip to content

Commit

Permalink
feat(maker): allow maker configs to be functions that return values b…
Browse files Browse the repository at this point in the history
…ased on arch

this allows more arguments to be passed through in the future, leaving this undocumented for now as
it's not a pattern I like but a pattern some people might find useful.  Will document once I get a
grip on how exactly I want this to be used.
  • Loading branch information
MarshallOfSound committed Apr 18, 2017
1 parent c23bfdf commit d9cbec5
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/makers/darwin/dmg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import path from 'path';
import pify from 'pify';

import { ensureFile } from '../../util/ensure-output';
import configFn from '../../util/config-fn';

export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { // eslint-disable-line
const outPath = path.resolve(dir, '../make', `${appName}.dmg`);
await ensureFile(outPath);
const dmgConfig = Object.assign({
overwrite: true,
}, forgeConfig.electronInstallerDMG, {
}, configFn(forgeConfig.electronInstallerDMG, targetArch), {
appPath: path.resolve(dir, `${appName}.app`),
name: appName,
out: path.dirname(outPath),
Expand Down
3 changes: 2 additions & 1 deletion src/makers/linux/deb.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import pify from 'pify';

import { ensureFile } from '../../util/ensure-output';
import configFn from '../../util/config-fn';

function debianArch(nodeArch) {
switch (nodeArch) {
Expand All @@ -24,7 +25,7 @@ export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { /
dest: path.dirname(outPath),
src: dir,
};
const debianConfig = Object.assign({}, forgeConfig.electronInstallerDebian, debianDefaults);
const debianConfig = Object.assign({}, configFn(forgeConfig.electronInstallerDebian, targetArch), debianDefaults);

await pify(installer)(debianConfig);
return [outPath];
Expand Down
3 changes: 2 additions & 1 deletion src/makers/linux/flatpak.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import pify from 'pify';

import { ensureFile } from '../../util/ensure-output';
import configFn from '../../util/config-fn';

function flatpakArch(nodeArch) {
switch (nodeArch) {
Expand All @@ -24,7 +25,7 @@ export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { /
dest: path.dirname(outPath),
src: dir,
};
const flatpakConfig = Object.assign({}, forgeConfig.electronInstallerFlatpak, flatpakDefaults);
const flatpakConfig = Object.assign({}, configFn(forgeConfig.electronInstallerFlatpak, targetArch), flatpakDefaults);

await pify(installer)(flatpakConfig);
return [outPath];
Expand Down
3 changes: 2 additions & 1 deletion src/makers/linux/rpm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import pify from 'pify';

import { ensureFile } from '../../util/ensure-output';
import configFn from '../../util/config-fn';

function rpmArch(nodeArch) {
switch (nodeArch) {
Expand All @@ -24,7 +25,7 @@ export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { /
dest: path.dirname(outPath),
src: dir,
};
const rpmConfig = Object.assign({}, forgeConfig.electronInstallerRedhat, rpmDefaults);
const rpmConfig = Object.assign({}, configFn(forgeConfig.electronInstallerRedhat, targetArch), rpmDefaults);

await pify(installer)(rpmConfig);
return [outPath];
Expand Down
3 changes: 2 additions & 1 deletion src/makers/win32/appx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from 'path';
import { spawnPromise, findActualExecutable } from 'spawn-rx';

import { ensureDirectory } from '../../util/ensure-output';
import configFn from '../../util/config-fn';

// NB: This is not a typo, we require AppXs to be built on 64-bit
// but if we're running in a 32-bit node.js process, we're going to
Expand Down Expand Up @@ -57,7 +58,7 @@ export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { /
packageDescription: packageJSON.description || appName,
packageExecutable: `app\\${appName}.exe`,
windowsKit: path.dirname(findSdkTool('makeappx.exe')),
}, forgeConfig.windowsStoreConfig, {
}, configFn(forgeConfig.windowsStoreConfig, targetArch), {
inputDirectory: dir,
outputDirectory: outPath,
});
Expand Down
4 changes: 3 additions & 1 deletion src/makers/win32/squirrel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs-promise';
import path from 'path';

import { ensureDirectory } from '../../util/ensure-output';
import configFn from '../../util/config-fn';

export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { // eslint-disable-line
const outPath = path.resolve(dir, `../make/squirrel.windows/${targetArch}`);
Expand All @@ -12,10 +13,11 @@ export default async (dir, appName, targetArch, forgeConfig, packageJSON) => { /
name: appName,
noMsi: true,
exe: `${appName}.exe`,
}, forgeConfig.electronWinstallerConfig, {
}, configFn(forgeConfig.electronWinstallerConfig, targetArch), {
appDirectory: dir,
outputDirectory: outPath,
});

await createWindowsInstaller(winstallerConfig);
const artifacts = [
path.resolve(outPath, 'RELEASES'),
Expand Down
6 changes: 6 additions & 0 deletions src/util/config-fn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default (configObject, ...args) => {
if (typeof configObject === 'function') {
return configObject(...args);
}
return configObject;
};

0 comments on commit d9cbec5

Please sign in to comment.