Skip to content

Commit d0567e9

Browse files
authored
Merge pull request #29 from oslabs-beta/Hooks-Test-Fix
TypeScript Additions
2 parents f37b6ac + efeb04c commit d0567e9

File tree

7 files changed

+35
-14
lines changed

7 files changed

+35
-14
lines changed

public/electron.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ function createWindow() {
4646
mainWindow.on('closed', () => (mainWindow = null));
4747

4848
// PTY PROCESS FOR IN APP TERMINAL
49-
const ptyProcess = pty.spawn(shell, [], {
49+
let ptyArgs = {
5050
name: 'xterm-color',
5151
cols: 80,
5252
rows: 80,
5353
cwd: process.env.HOME,
5454
env: process.env,
55-
});
55+
}
56+
57+
58+
const ptyProcess = pty.spawn(shell, [], ptyArgs);
5659
// with ptyProcess, we want to send incoming data to the channel terminal.incData
5760
ptyProcess.on('data', (data) => {
5861
mainWindow.webContents.send('terminal.incData', data);
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
1-
import React, { useEffect } from 'react';
1+
import React, { useEffect, ChangeEvent } from 'react';
22
import { XTerm } from 'xterm-for-react';
3+
import { TerminalType } from '../../utils/terminalTypes';
34

45
const { Terminal } = require('xterm');
56
const ipc = require('electron').ipcRenderer;
67

7-
const term = new Terminal({
8+
9+
const terminalArgs: TerminalType = {
810
fontSize: 15,
911
// Currently rows are hardcoded, next step is to make terminal sizing dynamic.
1012
rows: 30,
1113
fontFamily: 'monospace',
1214
theme: {
1315
background: '#002a36',
1416
},
15-
});
17+
};
18+
19+
const term = new Terminal(terminalArgs);
1620

17-
const TerminalGenerator = () => {
21+
const TerminalView = () => {
1822
useEffect(() => {
1923
// console.log(global.projectFilePath);
2024
term.open(document.getElementsByClassName('terminal')[0]);
2125
// when we have input events (e), we would send the data to the main processor
22-
term.onData((e) => {
26+
term.onData((e: ChangeEvent) => {
2327
ipc.send('terminal.toTerm', e);
2428
});
2529
// when incoming Data comes back to the main process, this ipc renderer
2630
// will take it and writes it to xterm monitor
27-
ipc.on('terminal.incData', (event, data) => {
31+
ipc.on('terminal.incData', (event, data: string) => {
2832
term.write(data);
2933
});
3034
}, []);
3135

32-
return <XTerm className='terminal' />;
36+
return <XTerm className="terminal" />;
3337
};
3438

35-
export default TerminalGenerator;
39+
export default TerminalView;

src/context/reducers/accTestCaseReducer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const AccTestCaseContext:any = createContext([]);
66

77
export const accTestCaseState: AccTestCaseState = {
88
modalOpen: false,
9-
109
describeId: 1,
1110
itId: 1,
1211
statementId: 1,

src/pages/RightPanel/RightPanel.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import EditorView from '../../components/EditorView/EditorView';
66
import BrowserView from '../../components/BrowserView/BrowserView';
77
import { GlobalContext } from '../../context/reducers/globalReducer';
88
import { closeRightPanel, setTabIndex } from '../../context/actions/globalActions';
9-
import TerminalGenerator from '../../components/Terminal/TerminalGenerator';
9+
import TerminalView from '../../components/Terminal/TerminalView';
1010
// import terminalStyles from '../../components/Terminal/TerminalView.module.scss';
1111
const closeIcon = require('../../assets/images/close.png');
1212

@@ -43,7 +43,7 @@ const RightPanel = () => {
4343
</div>
4444
{/* Test Terminal */}
4545
<div hidden={tabIndex !== 2} >
46-
<TerminalGenerator />
46+
<TerminalView />
4747
</div>
4848
</div>
4949
);

src/utils/ptyTypes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface PtyArgs {
2+
name: string,
3+
cols: number,
4+
rows: number,
5+
cwd: string,
6+
env: Object,
7+
}

src/utils/terminalTypes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface TerminalType {
2+
fontSize: number;
3+
rows: number;
4+
fontFamily?: string;
5+
theme?: {
6+
background?: string;
7+
};
8+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"noFallthroughCasesInSwitch": true
2222
},
2323
"include": [
24-
"src",
24+
"src/**/*",
2525
"src/context/__tests__",
2626
"__tests__/hello.test.js",
2727
"tests/spec.integra.js"

0 commit comments

Comments
 (0)