Skip to content

Commit

Permalink
Merge pull request #77 from catdad/missing-main-file
Browse files Browse the repository at this point in the history
fix for missing entry file in newer versions of electron
  • Loading branch information
catdad committed Apr 28, 2024
2 parents 5d64879 + 2cb725b commit ea846fa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
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

0 comments on commit ea846fa

Please sign in to comment.