Skip to content

Commit

Permalink
Adds a hook before MSICreator.create() is called
Browse files Browse the repository at this point in the history
This allows users to take advantage of the template configuration that electron-wix-msi provdes (see https://github.com/felixrieseberg/electron-wix-msi#template-configuration-optional for details)

trailing whitespace removal
  • Loading branch information
mako-taco authored and Jake Scott committed Nov 17, 2018
1 parent 19f0c03 commit 261db10
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 27 deletions.
6 changes: 6 additions & 0 deletions packages/maker/wix/src/Config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MSICreator } from "electron-wix-msi/lib/creator";

export interface MakerWixConfig {
/**
* String to set as appUserModelId on the shortcut. If none is passed, it'll
Expand Down Expand Up @@ -68,6 +70,10 @@ export interface MakerWixConfig {
* The password to decrypt the certificate given in `certificateFile`.
*/
certificatePassword?: string;
/**
* Allows for the modification of the MSICreator before create is called.
*/
beforeCreate?: (creator: MSICreator) => Promise<void> | void;
}
export interface UIOptions {
/**
Expand Down
63 changes: 36 additions & 27 deletions packages/maker/wix/src/MakerWix.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
import MakerBase, { MakerOptions } from '@electron-forge/maker-base';
import { ForgePlatform } from '@electron-forge/shared-types';
import MakerBase, { MakerOptions } from "@electron-forge/maker-base";
import { ForgePlatform } from "@electron-forge/shared-types";

import path from 'path';
import path from "path";

import getNameFromAuthor from './util/author-name';
import getNameFromAuthor from "./util/author-name";

import { MSICreator, MSICreatorOptions } from 'electron-wix-msi/lib/creator';
import { MSICreator, MSICreatorOptions } from "electron-wix-msi/lib/creator";

import { MakerWixConfig } from './Config';
import { MakerWixConfig } from "./Config";

export default class MakerWix extends MakerBase<MakerWixConfig> {
name = 'wix';
defaultPlatforms: ForgePlatform[] = ['win32'];
name = "wix";
defaultPlatforms: ForgePlatform[] = ["win32"];

isSupportedOnCurrentPlatform() {
return process.platform === 'win32';
return process.platform === "win32";
}

async make({
dir,
makeDir,
targetArch,
packageJSON,
appName,
}: MakerOptions) {
async make({ dir, makeDir, targetArch, packageJSON, appName }: MakerOptions) {
const outPath = path.resolve(makeDir, `/wix/${targetArch}`);
await this.ensureDirectory(outPath);

const creator = new MSICreator(Object.assign({
description: packageJSON.description,
name: appName,
version: packageJSON.version,
manufacturer: getNameFromAuthor(packageJSON.author),
exe: `${appName}.exe`,
}, this.config, {
appDirectory: dir,
outputDirectory: outPath,
}) as MSICreatorOptions);

const creator = new MSICreator(Object.assign(
{
description: packageJSON.description,
name: appName,
version: packageJSON.version,
manufacturer: getNameFromAuthor(packageJSON.author),
exe: `${appName}.exe`
},
this.config,
{
appDirectory: dir,
outputDirectory: outPath
}
) as MSICreatorOptions);

if (this.config.beforeCreate) {
await Promise.resolve(this.config.beforeCreate(creator));
}

<<<<<<< HEAD
=======
if (this.config.beforeCreate) {
await this.config.beforeCreate(creator);
}

>>>>>>> 2e0f42a... trailing whitespace removal
await creator.create();
const { msiFile } = await creator.compile();

Expand Down

0 comments on commit 261db10

Please sign in to comment.