electron / electron/forge

Default `ignore` can be accidentally overridden in `packagerConfig`

Open
#3,310 1 comment 3 reactions 0 assignees View on GitHub
package
Dominant language
TypeScript
Stars
7.1k
Forks
641
Avg merge
3d 1h
Merged PRs (30d)
30

Description

### Pre-flight checklist

- [X] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.

### Electron Forge version

6.0.5

### Electron version

v22.2.0

### Operating system

macOS 13.4.1

### Last known working Electron Forge version

_No response_

### Expected behavior

Specifying an `ignore` option in `packagerConfig` should not replace any default options (unless the `ignore` option is a function, as per electron-packager's [standard behaviour](https://github.com/electron/electron-packager/blob/e7fd45b5e1461d25c882eefee662f976ed0aa27b/src/copy-filter.js#L21)).

### Actual behavior

If `ignore` is not specified in `packagerConfig`, then it [defaults to](https://github.com/electron/forge/blob/74a8b5c17fee10231a0f4460b46a2127ded6cde5/packages/api/core/src/api/package.ts#L276C22-L276C33) `[/^\/out\//g]`. Setting `ignore` to any other value silently overrides this default.

As a consequence of this, the packager fails to remove the `out` directory.

For me, this results in the following crash:
```
An unhandled rejection has occurred inside Forge:
Error: Detected file "Contents/Resources/app/out/-darwin-arm64/.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework" that's the same in both x64 and arm64 builds and not covered by the x64ArchFiles rule: "undefined"
at exports.makeUniversalApp (/node_modules/@electron/universal/dist/cjs/index.js:101:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async packageUniversalMac (/node_modules/electron-packager/src/universal.js:56:3)
at async Promise.all (index 0)
at async packager (/node_modules/electron-packager/src/index.js:204:20)
```

### Steps to reproduce

I'm testing this by placing a `console.log(opts.ignore)` statement at the top of the `userPathFilter` function in `node_modules/electron-packager/src/copy-filter.js`.

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.