Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for missing entry file in newer versions of electron #77

Merged
merged 8 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ jobs:
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
node: [16, 18]
electron: [23, 20]
node: [20, 18]
electron: [30, 28, 23]
exclude:
# older electron seems to misbehave on apple silicon
- os: macos-latest
electron: 20
# there's an issue with signals in retry-cli on linux in node 20 🤷‍♀️
- os: ubuntu-latest
node: 20
include:
- os: ubuntu-latest
node: 14
node: 16
electron: 20
- os: ubuntu-latest
node: 16
electron: 18
- os: ubuntu-latest
node: 14
node: 16
electron: 16
- os: windows-latest
node: 14
Expand Down
20 changes: 20 additions & 0 deletions src/hook.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const electron = require('electron');
const required = require('runtime-required');
const path = require('path');

const logLevel = process.env.ELECTRONMON_LOGLEVEL || 'info';
const log = require('./log.js')(process.stdout, logLevel);
Expand All @@ -8,6 +9,25 @@ const queue = require('./message-queue.js');

const pathmap = {};

// we can get any number of arguments... best we can do
// is check if all of them resolve to a file, and if they do
// assume that file is a main process file
(function addMainFile(args) {
for (const arg of args) {
try {
const argPath = path.resolve(arg);
const file = require.resolve(argPath);
pathmap[file] = true;
queue({ type: 'discover', file });
} catch (e) {
// you know... because lint
e;
}
}
})(process.argv.slice(3));
// we run `electron --require hook.js ...`
// so remove the first 3 arguments

function exit(code) {
electron.app.on('will-quit', () => {
electron.app.exit(code);
Expand Down
Loading