@codebolt/codeboltjs 1.1.67 → 1.1.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -139,7 +139,7 @@ declare class Codebolt {
139
139
  prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
140
140
  eventNames(): (string | symbol)[];
141
141
  };
142
- executeCommand: (command: string, executeInMain?: boolean) => Promise<import("@codebolt/types").CommandOutput | import("@codebolt/types").CommandError>;
142
+ executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<unknown>;
143
143
  executeCommandRunUntilError: (command: string, executeInMain?: boolean) => Promise<import("@codebolt/types").CommandError>;
144
144
  sendManualInterrupt(): Promise<import("@codebolt/types").TerminalInterruptResponse>;
145
145
  executeCommandWithStream(command: string, executeInMain?: boolean): EventEmitter<[never]>;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
- import { CommandError, CommandOutput, TerminalInterruptResponse } from '@codebolt/types';
3
+ import { CommandError, TerminalInterruptResponse } from '@codebolt/types';
4
4
  /**
5
5
  * CustomEventEmitter class that extends the Node.js EventEmitter class.
6
6
  */
@@ -19,7 +19,7 @@ declare const cbterminal: {
19
19
  * @param {string} command - The command to be executed.
20
20
  * @returns {Promise<CommandOutput|CommandError>} A promise that resolves with the command's output, error, or finish signal.
21
21
  */
22
- executeCommand: (command: string, executeInMain?: boolean) => Promise<CommandOutput | CommandError>;
22
+ executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<unknown>;
23
23
  /**
24
24
  * Executes a given command and keeps running until an error occurs.
25
25
  * Listens for messages from the WebSocket and resolves the promise when an error is encountered.
@@ -23,31 +23,18 @@ const cbterminal = {
23
23
  * @param {string} command - The command to be executed.
24
24
  * @returns {Promise<CommandOutput|CommandError>} A promise that resolves with the command's output, error, or finish signal.
25
25
  */
26
- executeCommand: async (command, executeInMain = false) => {
26
+ executeCommand: async (command, returnEmptyStringOnSuccess = false) => {
27
27
  return new Promise((resolve, reject) => {
28
28
  websocket_1.default.getWebsocket.send(JSON.stringify({
29
29
  "type": "executeCommand",
30
30
  "message": command,
31
- executeInMain
31
+ returnEmptyStringOnSuccess
32
32
  }));
33
33
  let result = "";
34
34
  websocket_1.default.getWebsocket.on('message', (data) => {
35
35
  const response = JSON.parse(data);
36
- if (response.type === "commandOutput" || response.type === "commandError" || response.type === "commandFinish") {
37
- if (response.type === "commandOutput") {
38
- // Initialize result as an empty string
39
- result += response.stdout + "/n"; // Append the output
40
- }
41
- else if (response.type === "commandError") {
42
- result = response.stderr + "/n";
43
- ; // Set result to the error
44
- response.result = result;
45
- resolve(response); // Resolve with the result string
46
- }
47
- else if (response.type === "commandFinish") {
48
- response.result = result;
49
- resolve(response); // Resolve with the result string
50
- }
36
+ if (response.type === "commandError" || response.type === "commandFinish") {
37
+ resolve(response);
51
38
  }
52
39
  });
53
40
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.67",
3
+ "version": "1.1.68",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -19,29 +19,18 @@ const cbterminal = {
19
19
  * @param {string} command - The command to be executed.
20
20
  * @returns {Promise<CommandOutput|CommandError>} A promise that resolves with the command's output, error, or finish signal.
21
21
  */
22
- executeCommand: async (command: string,executeInMain=false): Promise<CommandOutput|CommandError> => {
22
+ executeCommand: async (command:string, returnEmptyStringOnSuccess:boolean = false) => {
23
23
  return new Promise((resolve, reject) => {
24
24
  cbws.getWebsocket.send(JSON.stringify({
25
25
  "type": "executeCommand",
26
26
  "message": command,
27
- executeInMain
27
+ returnEmptyStringOnSuccess
28
28
  }));
29
29
  let result = "";
30
- cbws.getWebsocket.on('message', (data: string) => {
30
+ cbws.getWebsocket.on('message', (data:string) => {
31
31
  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)
45
34
  }
46
35
  });
47
36
  });