I need to start the electron.js application programically. Below solution with execa library works, however I did not find the answer, how to make console to display console.log()
inside InitializeProject_GUI.js
(here is that question).
import executeExternalCommand, { ExecaReturnValue } from 'execa';
const executionResult: ExecaReturnValue<string> = await executeExternalCommand(
'electron',
['InitializeProject_GUI.js'],
{ cwd: __dirname }
);
So I decided to use standard child_process
instead. Maybe it will be easier to find how to display console.log()
's of child process, but first I need to make electron application start.
import ChildProcess, { ChildProcess as ChildProcess__type } from 'child_process';
const childProcess: ChildProcess__type = ChildProcess.spawn(
'electron',
['InitializeProject_GUI.js'],
{ cwd: __dirname }
);
I got Error: spawn electron ENOENT
:
Also, ChildProcess.exec('electron InitializeProject_GUI.js', { cwd: __dirname });
do NOTHING.
And, ChildProcess.execSync('electron InitializeProject_GUI.js', { cwd: __dirname });
causes the error with broken encoding: