Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
a4c188051a | |||
62195b63d6 | |||
16ba3803a4 | |||
613241cdcb |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartshell",
|
"name": "@pushrocks/smartshell",
|
||||||
"version": "2.0.21",
|
"version": "2.0.23",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartshell",
|
"name": "@pushrocks/smartshell",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "2.0.21",
|
"version": "2.0.23",
|
||||||
"description": "shell actions designed as promises",
|
"description": "shell actions designed as promises",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
@ -119,6 +119,10 @@ export class Smartshell {
|
|||||||
* executes a command async and strict, meaning it rejects the promise if something happens
|
* executes a command async and strict, meaning it rejects the promise if something happens
|
||||||
*/
|
*/
|
||||||
public async execStrict(commandStringArg: string): Promise<IExecResult> {
|
public async execStrict(commandStringArg: string): Promise<IExecResult> {
|
||||||
|
return (await this._exec(commandStringArg, false, true)) as IExecResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async execStrictSilent (commandStringArg: string): Promise<IExecResult> {
|
||||||
return (await this._exec(commandStringArg, true, true)) as IExecResult;
|
return (await this._exec(commandStringArg, true, true)) as IExecResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,17 +170,32 @@ export class Smartshell {
|
|||||||
* @param regexArg
|
* @param regexArg
|
||||||
*/
|
*/
|
||||||
public async execInteractive(commandStringArg: string) {
|
public async execInteractive(commandStringArg: string) {
|
||||||
|
if (process.env.CI) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
const shell = cp.spawn('sh', [], { stdio: 'pipe' });
|
const shell = cp.spawn('sh', [], { stdio: 'pipe' });
|
||||||
this.smartexit.addProcess(shell);
|
this.smartexit.addProcess(shell);
|
||||||
const shellLog = new ShellLog();
|
const shellLog = new ShellLog();
|
||||||
process.stdin.pipe(shell.stdin);
|
const stdInStream = process.stdin.pipe(shell.stdin);
|
||||||
shell.stdout.pipe(process.stdout);
|
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();
|
||||||
|
stdInStream.uncork();
|
||||||
|
stdOutStream.removeAllListeners();
|
||||||
|
stdOutStream.unpipe();
|
||||||
|
shell.kill('SIGTERM');
|
||||||
|
process.stdin.pause();
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
shell.stdin.write(commandStringArg + '\n');
|
let commandString = commandStringArg;
|
||||||
|
if (process.env.CI) {
|
||||||
|
commandString += ' && exit';
|
||||||
|
}
|
||||||
|
commandString += '\n';
|
||||||
|
|
||||||
|
shell.stdin.write(commandString);
|
||||||
await done.promise;
|
await done.promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user