fix(core): update

This commit is contained in:
2019-05-19 22:41:20 +02:00
parent 32c33cad5b
commit f63c4456bf
5 changed files with 126 additions and 129 deletions

View File

@ -73,22 +73,28 @@ export class ShellEnv {
this.sourceFileArray = [];
}
createEnvExecString(commandArg): string {
public createEnvExecString(commandArg: string): string {
let commandResult = '';
let sourceString = '';
// deal with sourcestring
for (const sourceFilePath of this.sourceFileArray) {
sourceString = sourceString + `source ${sourceFilePath} && `;
}
// deal with avaiable path
let pathString = 'PATH=$PATH';
for (const pathDir of this.pathDirArray) {
pathString += `:${pathDir}`;
}
pathString += ` && `;
switch (this.executor) {
case 'bash':
for (let sourceFilePath of this.sourceFileArray) {
sourceString = sourceString + `source ${sourceFilePath} && `;
}
commandResult = `bash -c '${sourceString}${commandArg}'`;
commandResult = `bash -c '${pathString}${sourceString}${commandArg}'`;
break;
case 'sh':
for (let sourceFilePath of this.sourceFileArray) {
sourceString = sourceString + `source ${sourceFilePath} && `;
}
commandResult = `${sourceString}${commandArg}`;
commandResult = `${pathString}${sourceString}${commandArg}`;
break;
}
commandResult = this._setPath(commandResult);

View File

@ -26,7 +26,8 @@ export interface IExecResultStreaming {
// -- SmartShell --
export class Smartshell {
shellEnv: ShellEnv;
public shellEnv: ShellEnv;
public smartexit = new plugins.smartexit.SmartExit();
constructor(optionsArg: IShellEnvContructorOptions) {
this.shellEnv = new ShellEnv(optionsArg);
@ -55,6 +56,8 @@ export class Smartshell {
detached: true
});
this.smartexit.addProcess(execChildProcess);
execChildProcess.stdout.on('data', data => {
if (!silentArg) {
spawnlogInstance.logToConsole(data);
@ -80,6 +83,7 @@ export class Smartshell {
}
execChildProcess.on('exit', (code, signal) => {
this.smartexit.removeProcess(execChildProcess);
if (strictArg && code === 1) {
done.reject();
}

View File

@ -1,4 +1,5 @@
import * as smartexit from '@pushrocks/smartexit';
import * as smartpromise from '@pushrocks/smartpromise';
import * as which from 'which';
export { smartpromise, which };
export { smartexit, smartpromise, which };