fix(core): update

This commit is contained in:
2024-04-18 13:42:51 +02:00
parent 980a2c9781
commit 415c9de553
5 changed files with 142 additions and 87 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartshell',
version: '3.0.4',
description: 'shell actions designed as promises'
version: '3.0.5',
description: 'A library for executing shell commands using promises.'
}

View File

@ -14,8 +14,10 @@ export interface IExecResult {
export interface IExecResultStreaming {
childProcess: cp.ChildProcess;
finalPromise: Promise<IExecResult>;
kill: () => void;
terminate: () => void;
kill: () => Promise<void>;
terminate: () => Promise<void>;
keyboardInterrupt: () => Promise<void>;
customSignal: (signalArg: plugins.smartexit.TProcessSignal) => Promise<void>;
}
export class Smartshell {
@ -114,13 +116,21 @@ export class Smartshell {
done.resolve({
childProcess: execChildProcess,
finalPromise: childProcessEnded.promise,
kill: () => {
kill: async () => {
console.log(`running tree kill with SIGKILL on process ${execChildProcess.pid}`);
plugins.treeKill(execChildProcess.pid, 'SIGKILL');
await plugins.smartexit.SmartExit.killTreeByPid(execChildProcess.pid, 'SIGKILL');
},
terminate: () => {
terminate: async () => {
console.log(`running tree kill with SIGTERM on process ${execChildProcess.pid}`);
plugins.treeKill(execChildProcess.pid, 'SIGTERM');
await plugins.smartexit.SmartExit.killTreeByPid(execChildProcess.pid, 'SIGTERM');
},
keyboardInterrupt: async () => {
console.log(`running tree kill with SIGINT on process ${execChildProcess.pid}`);
await plugins.smartexit.SmartExit.killTreeByPid(execChildProcess.pid, 'SIGINT');
},
customSignal: async (signalArg: plugins.smartexit.TProcessSignal) => {
console.log(`running tree kill with custom signal ${signalArg} on process ${execChildProcess.pid}`);
await plugins.smartexit.SmartExit.killTreeByPid(execChildProcess.pid, signalArg);
},
});
}

View File

@ -4,8 +4,3 @@ import * as smartpromise from '@push.rocks/smartpromise';
import which from 'which';
export { smartdelay, smartexit, smartpromise, which };
// third party
import treeKill from 'tree-kill';
export { treeKill };