Skip to content

Commit

Permalink
Merge pull request #40 from oslabs-beta/dev
Browse files Browse the repository at this point in the history
Merges cleaned dev with main
  • Loading branch information
brecht-horn authored May 3, 2023
2 parents a19ed0d + a47f0ef commit aa978f0
Show file tree
Hide file tree
Showing 45 changed files with 929 additions and 1,024 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
.DS_Store
build/
dist/
.DS_Store
Binary file modified build/icon.icns
Binary file not shown.
Binary file modified build/icon.ico
Binary file not shown.
48 changes: 34 additions & 14 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const { app, BrowserWindow, ipcMain, ipcRenderer } = require('electron');
const iconURL = './src/assets/kaptn.ico';
// const process = require('process');
const { app, BrowserWindow, ipcMain } = require('electron');
const { exec } = require('child_process');

const isDev = process.env.NODE_ENV === 'development';

function createMainWindow() {
const mainWindow = new BrowserWindow({
Expand All @@ -11,23 +12,42 @@ function createMainWindow() {
height: 700,
minWidth: 900,
minHeight: 600,
// icon: path.join(__dirname, '/kaptn.ico'),
webPreferences: {
nodeIntegration: true,
}
contextIsolation: false,
},
});

// if (isDev) {
// mainWindow.loadURL('http://localhost:4444/');
// } else {
// mainWindow.loadFile(path.join(__dirname, '/build/index.html'))
// }
// mainWindow.loadFile(path.join(app.getAppPath(), 'dist/index.html'));
mainWindow.loadURL('http://localhost:4444/');
// mainWindow.webContents.openDevTools();
if (isDev) {
mainWindow.loadURL('http://localhost:4444/');
mainWindow.webContents.openDevTools();
} else {
// In production, render the html build file
mainWindow.loadURL(`file://${path.join(__dirname, '/dist/index.html#/')}`);
}
}

/******** EVENT LISTENERS ********/

// Listen to post_command event
ipcMain.on('post_command', (event, arg) => {
const { command, currDir } = arg;

exec(` ${command}`, { cwd: currDir }, (err, stdout, stderr) => {
// Handle failed command execution
if (err) {
return err;
}
// Handle successful command execution but returned error (stderr)
if (stderr) {
return event.sender.send('post_command', stderr);
}
// Handle successful command execution with no errors
return event.sender.send('post_command', stdout);
});
});

// Load the main window
app.whenReady().then(() => {
createMainWindow();
});

Loading

0 comments on commit aa978f0

Please sign in to comment.