Skip to content

Commit

Permalink
adding the entry file to the main process list based on the command t…
Browse files Browse the repository at this point in the history
…hat starts the app
  • Loading branch information
catdad committed Apr 28, 2024
1 parent 5b6b798 commit 1f4609c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 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,21 @@ 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 opt of args) {
const optPath = path.resolve(opt);

try {
const file = require.resolve(optPath);
pathmap[file] = true;
queue({ type: 'discover', file });
} catch (e) {}
}
})(process.argv.slice(3));

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

0 comments on commit 1f4609c

Please sign in to comment.