Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://www.twilio.com/blog/an-introduction-to-building-desktop-applications-with-electron
- const { app, BrowserWindow, ipcMain } = require('electron');
- const path = require('path');
- const loadMainWindow = () => {
- const mainWindow = new BrowserWindow({
- width: 1200,
- height: 800,
- webPreferences: {
- nodeIntegration: true
- }
- });
- mainWindow.loadFile(path.join(__dirname, "app/index.html"));
- };
- app.on('ready', loadMainWindow);
- app.on('window-all-closed', () => {
- if (process.platform !== "darwin") {
- app.quit();
- }
- });
- app.on('activate', () => {
- if (BrowserWindow.getAllWindows().length === 0) {
- loadMainWindow();
- }
- });
- // integrated terminal
- const { exec } = require('child_process');
- // shell output example for later:
- /*
- exec('ls -la', (error, stdout, stderr) => {
- if (error) {
- console.log(`ERROR: ${error.message}`);
- return;
- }
- if (stderr) {
- console.log(`STDERR: ${stderr}`);
- return;
- }
- console.log(`stdout: ${stdout}`);
- });
- */
- // communicate between main.js and app/app.js and app/compiler.js
- ipcMain.on('get-terminal-command', (event, args) => {
- // check if the message went through, still nothing to do with the terminal.
- console.log(args);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement