1- const { app, BrowserWindow, ipcMain, dialog } = require ( 'electron' ) ;
1+ const {
2+ app, BrowserWindow, ipcMain, dialog,
3+ } = require ( 'electron' ) ;
24const path = require ( 'path' ) ;
35const isDev = require ( 'electron-is-dev' ) ;
46const fs = require ( 'fs' ) ;
57const os = require ( 'os' ) ;
68const pty = require ( 'node-pty' ) ;
79
8- //Dynamic variable to change terminal type based on os
9- let shell = os . platform ( ) === 'win32' ? 'powershell.exe' : 'bash' ;
10-
11-
12-
10+ // Dynamic variable to change terminal type based on os
11+ const shell = os . platform ( ) === 'win32' ? 'powershell.exe' : 'bash' ;
1312let mainWindow ;
1413
1514if ( isDev ) console . log ( 'electron version' , process . versions . electron ) ;
@@ -41,44 +40,42 @@ function createWindow() {
4140 } ,
4241 } ) ;
4342 mainWindow . loadURL (
44- isDev ? 'http://localhost:3000' : `file://${ path . join ( __dirname , '../build/index.html' ) } `
43+ isDev ? 'http://localhost:3000' : `file://${ path . join ( __dirname , '../build/index.html' ) } ` ,
4544 ) ;
4645 mainWindow . on ( 'closed' , ( ) => ( mainWindow = null ) ) ;
4746
4847 // PTY PROCESS FOR IN APP TERMINAL
49- let ptyArgs = {
48+ const ptyArgs = {
5049 name : 'xterm-color' ,
5150 cols : 80 ,
5251 rows : 80 ,
5352 cwd : process . env . HOME ,
5453 env : process . env ,
55- }
56-
54+ } ;
5755
5856 const ptyProcess = pty . spawn ( shell , [ ] , ptyArgs ) ;
5957 // with ptyProcess, we want to send incoming data to the channel terminal.incData
6058 ptyProcess . on ( 'data' , ( data ) => {
6159 mainWindow . webContents . send ( 'terminal.incData' , data ) ;
6260 } ) ;
63- // in the main process, at terminal.toTerm channel, when data is received,
61+ // in the main process, at terminal.toTerm channel, when data is received,
6462 // main process will write to ptyProcess
65- ipcMain . on ( 'terminal.toTerm' , function ( event , data ) {
63+ ipcMain . on ( 'terminal.toTerm' , ( event , data ) => {
6664 ptyProcess . write ( data ) ;
67- } )
68- } ;
69-
65+ } ) ;
66+ }
7067
7168// EDITORVIEW.JSX SAVE FILE FUNCTIONALITY
7269ipcMain . on ( 'EditorView.saveFile' , ( e , filePath , editedText ) => {
7370 fs . writeFile ( filePath , editedText , ( err ) => {
7471 if ( err ) throw err ;
7572 } ) ;
7673 // Return a success message upon save
77- e . returnValue = 'Changes Saved'
74+ e . returnValue = 'Changes Saved' ;
7875} ) ;
7976
8077/*
81- EXPORTFILEMODAL.JSX FILE FUNCTIONALITY
78+ EXPORTFILEMODAL.JSX FILE FUNCTIONALITY
8279 (check existence and create folder)
8380*/
8481ipcMain . on ( 'ExportFileModal.exists' , ( e , fileOrFolderPath ) => {
@@ -106,11 +103,11 @@ ipcMain.on('ExportFileModal.readFile', (e, filePath) => {
106103} ) ;
107104
108105// OPENFOLDERBUTTON.JSX FILE FUNCTIONALITY
109- ipcMain . on ( 'OpenFolderButton.isDirectory' , ( e , filePath ) => {
106+ ipcMain . on ( 'OpenFolderButton.isDirectory' , ( e , filePath ) => {
110107 e . returnValue = fs . statSync ( filePath ) . isDirectory ( ) ;
111108} ) ;
112109
113- ipcMain . on ( 'OpenFolderButton.dialog' , ( e ) => {
110+ ipcMain . on ( 'OpenFolderButton.dialog' , ( e ) => {
114111 const dialogOptions = {
115112 properties : [ 'openDirectory' , 'createDirectory' ] ,
116113 filters : [
@@ -127,7 +124,7 @@ ipcMain.on('OpenFolderButton.dialog' , (e) => {
127124UNIVERSAL IPC CALLS
128125(The following IPC calls are made from various components in the codebase)
129126*/
130- ipcMain . on ( 'Universal.stat' , ( e , filePath ) => {
127+ ipcMain . on ( 'Universal.stat' , ( e , filePath ) => {
131128 e . returnValue = fs . statSync ( filePath ) . isDirectory ( ) ;
132129} ) ;
133130
@@ -164,4 +161,4 @@ app.on('activate', () => {
164161 if ( mainWindow === null ) {
165162 createWindow ( ) ;
166163 }
167- } ) ;
164+ } ) ;
0 commit comments