diff --git a/package.json b/package.json index 99de344..c10d913 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@gitzone/tsbuild": "^2.1.66", "@gitzone/tsrun": "^1.2.42", "@gitzone/tstest": "^1.0.74", - "@pushrocks/tapbundle": "^5.0.4", + "@pushrocks/tapbundle": "^5.0.8", "@types/node": "^20.3.1" }, "dependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3013b2e..0222502 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,8 +35,8 @@ devDependencies: specifier: ^1.0.74 version: 1.0.74(@types/node@20.3.1) '@pushrocks/tapbundle': - specifier: ^5.0.4 - version: 5.0.4 + specifier: ^5.0.8 + version: 5.0.8 '@types/node': specifier: ^20.3.1 version: 20.3.1 @@ -388,7 +388,7 @@ packages: '@pushrocks/smartlog': 3.0.2 '@pushrocks/smartpromise': 3.1.10 '@pushrocks/smartshell': 2.0.30 - '@pushrocks/tapbundle': 5.0.4 + '@pushrocks/tapbundle': 5.0.8 figures: 5.0.0 transitivePeerDependencies: - '@swc/core' @@ -632,11 +632,11 @@ packages: '@pushrocks/lik': 4.0.22 '@pushrocks/smartdelay': 2.0.13 - /@pushrocks/smartexpect@1.0.14: - resolution: {integrity: sha512-YIvRFNQbNZ87EDK45evj4XpX6KaBpuPnIKEafZGSpncNTm30VcMATRgcxqk/x9f8hm1p1i4QMwmSr4MuF0cCWQ==} + /@pushrocks/smartexpect@1.0.15: + resolution: {integrity: sha512-ABhsgmTqE1cfL6m0qpicZf6FdfuUip3oJR8CDr9wZwkBODKpahv7lHqeN0EjdvaJuHyqqcd3m1WaHmLPEyZ63A==} dependencies: - '@pushrocks/smartdelay': 2.0.13 - '@pushrocks/smartpromise': 3.1.10 + '@pushrocks/smartdelay': 3.0.1 + '@pushrocks/smartpromise': 4.0.2 fast-deep-equal: 3.1.3 dev: true @@ -1013,15 +1013,16 @@ packages: through2: 4.0.2 dev: true - /@pushrocks/tapbundle@5.0.4: - resolution: {integrity: sha512-sEUepgMsH+abdtBGN0FSTHhJzG/IpZ1XVDm8YF6ma21A6Z8DUXTbEbpGWC/Goi2HCSkgHNxmgMSshT1zAO/xXA==} + /@pushrocks/tapbundle@5.0.8: + resolution: {integrity: sha512-w6oyVA1VYht5/OnUrWrvdDqBpb3H5ao3LATKauTG9wSyOng65/8ttAbhHqg5Jo39Hlib9QYbLH3QQyLfukfxCw==} dependencies: '@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/smartexpect': 1.0.14 - '@pushrocks/smartpromise': 3.1.10 - '@pushrocks/smarttime': 3.0.50 + '@pushrocks/smartexpect': 1.0.15 + '@pushrocks/smartpromise': 4.0.2 + '@pushrocks/smarttime': 4.0.1 transitivePeerDependencies: - bufferutil - supports-color diff --git a/test/test.ts b/test/test.ts index 95a62e1..ee07b10 100644 --- a/test/test.ts +++ b/test/test.ts @@ -15,12 +15,12 @@ tap.test('smartshell should create a Smartshell instance', async () => { tap.test('smartshell should run async', async () => { 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 () => { 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 () => { @@ -30,7 +30,7 @@ tap.test('smartshell should stream a shell execution', async () => { done.resolve(data); }); let data = await done.promise; - // expect(data).toMatch(/[0-9\.]*/); + expect(data).toMatch(/[0-9\.]*/); await execStreamingResponse.finalPromise; }); @@ -49,7 +49,7 @@ tap.test('should be able to find git', async () => { }); tap.test('should spawn an interactive cli', async () => { - // await testSmartshell.execInteractive('echo "hi"'); + await testSmartshell.execInteractive('echo "hi"'); }); tap.start({ diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 8a074ff..8dac35e 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@pushrocks/smartshell', - version: '3.0.0', + version: '3.0.1', description: 'shell actions designed as promises' } diff --git a/ts/smartshell.classes.smartshell.ts b/ts/smartshell.classes.smartshell.ts index 32df977..8892d45 100644 --- a/ts/smartshell.classes.smartshell.ts +++ b/ts/smartshell.classes.smartshell.ts @@ -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(); const childProcessEnded = plugins.smartpromise.defer();