@nu-art/commando 0.204.90 → 0.204.91

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/commando",
3
- "version": "0.204.90",
3
+ "version": "0.204.91",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -47,7 +47,7 @@ export declare class CommandoInteractive extends BaseCommando {
47
47
  * @param {string | RegExp} filter - The pattern to match in log entries.
48
48
  * @param {(match: RegExpMatchArray) => any} callback - The callback to execute when a match is found.
49
49
  */
50
- onLog(filter: string | RegExp, callback: (match: RegExpMatchArray) => any): void;
50
+ onLog(filter: string | RegExp, callback: (match: RegExpMatchArray) => any): this;
51
51
  /**
52
52
  * Executes commands asynchronously and listens for the PID.
53
53
  *
@@ -79,6 +79,7 @@ class CommandoInteractive extends BaseCommando_1.BaseCommando {
79
79
  return true;
80
80
  };
81
81
  this.addLogProcessor(pidLogProcessor);
82
+ return this;
82
83
  }
83
84
  /**
84
85
  * Executes commands asynchronously and listens for the PID.
@@ -88,11 +89,9 @@ class CommandoInteractive extends BaseCommando_1.BaseCommando {
88
89
  * @returns {Promise<T>} - The result of the callback function.
89
90
  */
90
91
  async executeAsync(pidListener, callback) {
91
- const uniqueFunctionName = (0, ts_common_1.generateHex)(16);
92
92
  const pidUniqueKey = (0, ts_common_1.generateHex)(16);
93
93
  const regexp = new RegExp(`${pidUniqueKey}=(\\d+)`);
94
- const functionContent = this.builder.reset();
95
- const functionName = `${uniqueFunctionName}() {`;
94
+ const functionContent = this.builder.reset().trim() + ' &';
96
95
  const pidLogProcessor = (log) => {
97
96
  const match = log.match(regexp);
98
97
  if (!match)
@@ -102,13 +101,10 @@ class CommandoInteractive extends BaseCommando_1.BaseCommando {
102
101
  return false;
103
102
  };
104
103
  return await this
105
- .append(functionName)
106
104
  .append(functionContent)
107
- .append('}')
108
- .append(`${uniqueFunctionName} &`)
109
105
  .append('pid=$!')
110
106
  .append(`echo "${pidUniqueKey}=\${pid}"`)
111
- .append(`wait \$pid`)
107
+ .append(`wait \$pid`).debug(true)
112
108
  .addLogProcessor(pidLogProcessor)
113
109
  .execute(callback);
114
110
  }
@@ -42,7 +42,9 @@ class InteractiveShell extends ts_common_1.Logger {
42
42
  this.kill = (signal) => {
43
43
  if (!this.alive)
44
44
  return;
45
- return this.shell.kill(signal);
45
+ this.logWarning(`Killing......`);
46
+ // return this.gracefullyKill(this.shell.pid);
47
+ return this.shell.emit('exit', 2);
46
48
  };
47
49
  /**
48
50
  * Attempts to gracefully terminate the shell process.