fix(core): update

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

View File

@ -29,7 +29,7 @@
"@gitzone/tsbuild": "^2.1.66", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.42", "@gitzone/tsrun": "^1.2.42",
"@gitzone/tstest": "^1.0.74", "@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^5.0.4", "@pushrocks/tapbundle": "^5.0.8",
"@types/node": "^20.3.1" "@types/node": "^20.3.1"
}, },
"dependencies": { "dependencies": {

27
pnpm-lock.yaml generated
View File

@ -35,8 +35,8 @@ devDependencies:
specifier: ^1.0.74 specifier: ^1.0.74
version: 1.0.74(@types/node@20.3.1) version: 1.0.74(@types/node@20.3.1)
'@pushrocks/tapbundle': '@pushrocks/tapbundle':
specifier: ^5.0.4 specifier: ^5.0.8
version: 5.0.4 version: 5.0.8
'@types/node': '@types/node':
specifier: ^20.3.1 specifier: ^20.3.1
version: 20.3.1 version: 20.3.1
@ -388,7 +388,7 @@ packages:
'@pushrocks/smartlog': 3.0.2 '@pushrocks/smartlog': 3.0.2
'@pushrocks/smartpromise': 3.1.10 '@pushrocks/smartpromise': 3.1.10
'@pushrocks/smartshell': 2.0.30 '@pushrocks/smartshell': 2.0.30
'@pushrocks/tapbundle': 5.0.4 '@pushrocks/tapbundle': 5.0.8
figures: 5.0.0 figures: 5.0.0
transitivePeerDependencies: transitivePeerDependencies:
- '@swc/core' - '@swc/core'
@ -632,11 +632,11 @@ packages:
'@pushrocks/lik': 4.0.22 '@pushrocks/lik': 4.0.22
'@pushrocks/smartdelay': 2.0.13 '@pushrocks/smartdelay': 2.0.13
/@pushrocks/smartexpect@1.0.14: /@pushrocks/smartexpect@1.0.15:
resolution: {integrity: sha512-YIvRFNQbNZ87EDK45evj4XpX6KaBpuPnIKEafZGSpncNTm30VcMATRgcxqk/x9f8hm1p1i4QMwmSr4MuF0cCWQ==} resolution: {integrity: sha512-ABhsgmTqE1cfL6m0qpicZf6FdfuUip3oJR8CDr9wZwkBODKpahv7lHqeN0EjdvaJuHyqqcd3m1WaHmLPEyZ63A==}
dependencies: dependencies:
'@pushrocks/smartdelay': 2.0.13 '@pushrocks/smartdelay': 3.0.1
'@pushrocks/smartpromise': 3.1.10 '@pushrocks/smartpromise': 4.0.2
fast-deep-equal: 3.1.3 fast-deep-equal: 3.1.3
dev: true dev: true
@ -1013,15 +1013,16 @@ packages:
through2: 4.0.2 through2: 4.0.2
dev: true dev: true
/@pushrocks/tapbundle@5.0.4: /@pushrocks/tapbundle@5.0.8:
resolution: {integrity: sha512-sEUepgMsH+abdtBGN0FSTHhJzG/IpZ1XVDm8YF6ma21A6Z8DUXTbEbpGWC/Goi2HCSkgHNxmgMSshT1zAO/xXA==} resolution: {integrity: sha512-w6oyVA1VYht5/OnUrWrvdDqBpb3H5ao3LATKauTG9wSyOng65/8ttAbhHqg5Jo39Hlib9QYbLH3QQyLfukfxCw==}
dependencies: dependencies:
'@open-wc/testing': 3.2.0 '@open-wc/testing': 3.2.0
'@pushrocks/smartdelay': 2.0.13 '@open-wc/testing-helpers': 2.3.0
'@pushrocks/smartdelay': 3.0.1
'@pushrocks/smartenv': 5.0.5 '@pushrocks/smartenv': 5.0.5
'@pushrocks/smartexpect': 1.0.14 '@pushrocks/smartexpect': 1.0.15
'@pushrocks/smartpromise': 3.1.10 '@pushrocks/smartpromise': 4.0.2
'@pushrocks/smarttime': 3.0.50 '@pushrocks/smarttime': 4.0.1
transitivePeerDependencies: transitivePeerDependencies:
- bufferutil - bufferutil
- supports-color - supports-color

View File

@ -15,12 +15,12 @@ tap.test('smartshell should create a Smartshell instance', async () => {
tap.test('smartshell should run async', async () => { tap.test('smartshell should run async', async () => {
let execResult = await testSmartshell.exec('npm -v'); let execResult = await testSmartshell.exec('npm -v');
// expect(execResult.stdout).toMatch(/[0-9\.]*/); expect(execResult.stdout).toMatch(/[0-9\.]*/);
}); });
tap.test('smartshell should run async and silent', async () => { tap.test('smartshell should run async and silent', async () => {
let execResult = await testSmartshell.execSilent('npm -v'); let execResult = await testSmartshell.execSilent('npm -v');
// expect(execResult.stdout).toMatch(/[0-9\.]*/); expect(execResult.stdout).toMatch(/[0-9\.]*/);
}); });
tap.test('smartshell should stream a shell execution', async () => { tap.test('smartshell should stream a shell execution', async () => {
@ -30,7 +30,7 @@ tap.test('smartshell should stream a shell execution', async () => {
done.resolve(data); done.resolve(data);
}); });
let data = await done.promise; let data = await done.promise;
// expect(data).toMatch(/[0-9\.]*/); expect(data).toMatch(/[0-9\.]*/);
await execStreamingResponse.finalPromise; await execStreamingResponse.finalPromise;
}); });
@ -49,7 +49,7 @@ tap.test('should be able to find git', async () => {
}); });
tap.test('should spawn an interactive cli', async () => { tap.test('should spawn an interactive cli', async () => {
// await testSmartshell.execInteractive('echo "hi"'); await testSmartshell.execInteractive('echo "hi"');
}); });
tap.start({ tap.start({

View File

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

View File

@ -43,35 +43,25 @@ export class Smartshell {
} }
const done = plugins.smartpromise.defer(); 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); this.smartexit.addProcess(shell);
const stdInStream = process.stdin.pipe(shell.stdin);
const stdOutStream = shell.stdout.pipe(process.stdout);
shell.on('close', (code) => { shell.on('close', (code) => {
console.log(`interactive shell terminated with code ${code}`); console.log(`interactive shell terminated with code ${code}`);
stdInStream.removeAllListeners(); this.smartexit.removeProcess(shell);
stdInStream.uncork();
stdOutStream.removeAllListeners();
stdOutStream.unpipe();
shell.kill('SIGTERM');
process.stdin.pause();
done.resolve(); done.resolve();
}); });
let commandString = options.commandString; 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; await done.promise;
return; return;
} }
const done = plugins.smartpromise.defer<IExecResult | IExecResultStreaming>(); const done = plugins.smartpromise.defer<IExecResult | IExecResultStreaming>();
const childProcessEnded = plugins.smartpromise.defer<IExecResult>(); const childProcessEnded = plugins.smartpromise.defer<IExecResult>();