mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-09 15:38:43 +00:00
38 lines
1003 B
JavaScript
38 lines
1003 B
JavaScript
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
|
const { spawn } = require('child_process');
|
|
const path = require('path');
|
|
const which = require('which');
|
|
|
|
function createWindow() {
|
|
const win = new BrowserWindow({
|
|
width: 800,
|
|
height: 600,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.js')
|
|
}
|
|
});
|
|
win.loadFile('index.html');
|
|
}
|
|
|
|
app.whenReady().then(createWindow);
|
|
|
|
ipcMain.handle('run-quickstart', async () => {
|
|
const voxveraPath = which.sync('voxvera', { nothrow: true });
|
|
if (!voxveraPath) {
|
|
dialog.showErrorBox(
|
|
'voxvera not found',
|
|
'Install the voxvera CLI and ensure it is in your PATH.'
|
|
);
|
|
return -1;
|
|
}
|
|
return new Promise((resolve, reject) => {
|
|
const proc = spawn(voxveraPath, ['quickstart'], { stdio: 'inherit' });
|
|
proc.on('close', code => resolve(code));
|
|
proc.on('error', err => reject(err));
|
|
});
|
|
});
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') app.quit();
|
|
});
|