fix(core): update

This commit is contained in:
2023-06-22 13:54:39 +02:00
parent ec29db26ef
commit c5937da870
5 changed files with 34 additions and 43 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartshell',
version: '3.0.0',
version: '3.0.1',
description: 'shell actions designed as promises'
}

View File

@ -39,38 +39,28 @@ export class Smartshell {
if (options.interactive) {
if (process.env.CI) {
return;
return;
}
const done = plugins.smartpromise.defer();
const shell = cp.spawn('sh', [], { stdio: 'pipe' });
const shell = cp.spawn('sh', [], { stdio: ['pipe', 'inherit', 'inherit'] });
this.smartexit.addProcess(shell);
const stdInStream = process.stdin.pipe(shell.stdin);
const stdOutStream = shell.stdout.pipe(process.stdout);
shell.on('close', (code) => {
console.log(`interactive shell terminated with code ${code}`);
stdInStream.removeAllListeners();
stdInStream.uncork();
stdOutStream.removeAllListeners();
stdOutStream.unpipe();
shell.kill('SIGTERM');
process.stdin.pause();
done.resolve();
console.log(`interactive shell terminated with code ${code}`);
this.smartexit.removeProcess(shell);
done.resolve();
});
let commandString = options.commandString;
if (process.env.CI) {
commandString += ' && exit';
}
commandString += '\n';
shell.stdin.write(commandString);
shell.stdin.write(commandString + '\n exit \n');
await done.promise;
return;
}
}
const done = plugins.smartpromise.defer<IExecResult | IExecResultStreaming>();
const childProcessEnded = plugins.smartpromise.defer<IExecResult>();