You need to run the program installed on Windows (C:Program FilesSparkSpark.exe) in the program window on NodeJS Electron. How to implement it? It is in the window, not separately!
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
const pty = require('node-pty');
let mainWindow;
let ptyProcess;
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
},
});
mainWindow.loadFile('index.html');
}
app.whenReady().then(() => {
createWindow();
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
});
ipcMain.on('start-spark', (event) => {
ptyProcess = pty.spawn('cmd.exe', ['/c', 'C:\Program Files\Spark\Spark.exe'], {
name: 'xterm-color',
cols: 80,
rows: 24,
cwd: process.env.HOME,
env: process.env
});
ptyProcess.on('data', (data) => {
mainWindow.webContents.send('terminal-output', data);
});
});