Skip to content

Commit

Permalink
fix(packager): allow hooks to be strings or functions depending on co…
Browse files Browse the repository at this point in the history
…nfig setup
  • Loading branch information
MarshallOfSound committed Dec 17, 2016
1 parent 2d44c41 commit ec0caec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ config object:
You can set `electronPackagerConfig` with **any** of the options from
[Electron Packager](https://github.com/electron-userland/electron-packager/blob/master/docs/api.md).

**NOTE:** The `afterCopy` and `afterExtract` options are mapped to `require`
calls internally, so provide a path to a file that exports your hooks and they
will still run.

**NOTE:** You can also set your `forge` config property of your package.json to point to a JS file the exports the config object like so.
**NOTE:** You can also set your `forge` config property of your package.json to point to a JS file the exports the config object:

```js
{
Expand All @@ -139,4 +135,8 @@ will still run.
}
...
}
```
```

**NOTE:** If you use the JSON object then the `afterCopy` and `afterExtract` options are mapped to `require`
calls internally, so provide a path to a file that exports your hooks and they will still run. If you use
the JS file method mentioned above then you can use functions normally.
8 changes: 6 additions & 2 deletions src/electron-forge-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ const main = async () => {
await rebuildHook(buildPath, electronVersion, pPlatform, pArch);
packagerSpinner = ora.ora('Packaging Application').start();
done();
}].concat(forgeConfig.electronPackagerConfig.afterCopy ? forgeConfig.electronPackagerConfig.afterCopy.map(item => require(item)) : []),
afterExtract: forgeConfig.electronPackagerConfig.afterExtract ? forgeConfig.electronPackagerConfig.afterExtract.map(item => require(item)) : [],
}].concat(forgeConfig.electronPackagerConfig.afterCopy ? forgeConfig.electronPackagerConfig.afterCopy.map(item =>
(typeof item === 'string' ? require(item) : item)
) : []),
afterExtract: forgeConfig.electronPackagerConfig.afterExtract ? forgeConfig.electronPackagerConfig.afterExtract.map(item =>
(typeof item === 'string' ? require(item) : item)
) : [],
dir,
arch,
platform,
Expand Down

0 comments on commit ec0caec

Please sign in to comment.