Skip to content

Commit ec0caec

Browse files
fix(packager): allow hooks to be strings or functions depending on config setup
1 parent 2d44c41 commit ec0caec

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ config object:
125125
You can set `electronPackagerConfig` with **any** of the options from
126126
[Electron Packager](https://github.com/electron-userland/electron-packager/blob/master/docs/api.md).
127127

128-
**NOTE:** The `afterCopy` and `afterExtract` options are mapped to `require`
129-
calls internally, so provide a path to a file that exports your hooks and they
130-
will still run.
131-
132-
**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.
128+
**NOTE:** You can also set your `forge` config property of your package.json to point to a JS file the exports the config object:
133129

134130
```js
135131
{
@@ -139,4 +135,8 @@ will still run.
139135
}
140136
...
141137
}
142-
```
138+
```
139+
140+
**NOTE:** If you use the JSON object then the `afterCopy` and `afterExtract` options are mapped to `require`
141+
calls internally, so provide a path to a file that exports your hooks and they will still run. If you use
142+
the JS file method mentioned above then you can use functions normally.

src/electron-forge-package.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ const main = async () => {
7373
await rebuildHook(buildPath, electronVersion, pPlatform, pArch);
7474
packagerSpinner = ora.ora('Packaging Application').start();
7575
done();
76-
}].concat(forgeConfig.electronPackagerConfig.afterCopy ? forgeConfig.electronPackagerConfig.afterCopy.map(item => require(item)) : []),
77-
afterExtract: forgeConfig.electronPackagerConfig.afterExtract ? forgeConfig.electronPackagerConfig.afterExtract.map(item => require(item)) : [],
76+
}].concat(forgeConfig.electronPackagerConfig.afterCopy ? forgeConfig.electronPackagerConfig.afterCopy.map(item =>
77+
(typeof item === 'string' ? require(item) : item)
78+
) : []),
79+
afterExtract: forgeConfig.electronPackagerConfig.afterExtract ? forgeConfig.electronPackagerConfig.afterExtract.map(item =>
80+
(typeof item === 'string' ? require(item) : item)
81+
) : [],
7882
dir,
7983
arch,
8084
platform,

0 commit comments

Comments
 (0)