Skip to content

Commit 01e4bdd

Browse files
changes in terminal
1 parent ad28cff commit 01e4bdd

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codebolt/codeboltjs",
3-
"version": "1.1.67",
3+
"version": "1.1.68",
44
"description": "",
55
"keywords": [],
66
"author": "",

src/modules/terminal.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,22 @@ const cbterminal = {
1919
* @param {string} command - The command to be executed.
2020
* @returns {Promise<CommandOutput|CommandError>} A promise that resolves with the command's output, error, or finish signal.
2121
*/
22-
executeCommand: async (command: string,executeInMain=false): Promise<CommandOutput|CommandError> => {
22+
executeCommand: async (command:string, returnEmptyStringOnSuccess = false) => {
2323
return new Promise((resolve, reject) => {
2424
cbws.getWebsocket.send(JSON.stringify({
2525
"type": "executeCommand",
2626
"message": command,
27-
executeInMain
27+
returnEmptyStringOnSuccess
2828
}));
2929
let result = "";
30-
cbws.getWebsocket.on('message', (data: string) => {
30+
cbws.getWebsocket.on('message', (data:string) => {
3131
const response = JSON.parse(data);
32-
33-
if (response.type === "commandOutput" || response.type === "commandError" || response.type === "commandFinish") {
34-
if (response.type === "commandOutput") {
35-
// Initialize result as an empty string
36-
result += response.stdout + "/n"; // Append the output
37-
} else if (response.type === "commandError") {
38-
result = response.stderr + "/n";; // Set result to the error
39-
response.result = result;
40-
resolve(response); // Resolve with the result string
41-
} else if (response.type === "commandFinish") {
42-
response.result = result;
43-
resolve(response); // Resolve with the result string
44-
}
32+
if (response.type === "commandError" || response.type === "commandFinish" ) {
33+
resolve(response)
4534
}
4635
});
4736
});
48-
},
37+
},,
4938

5039
/**
5140
* Executes a given command and keeps running until an error occurs.

0 commit comments

Comments
 (0)