Compare commits

...

13 Commits

Author SHA1 Message Date
e981ca6bdd 2.0.13 2018-12-14 18:36:23 +01:00
2853a48708 fix(core): update 2018-12-14 18:36:23 +01:00
389f8f4a52 2.0.12 2018-12-14 18:35:31 +01:00
c1a537f052 fix(core): update 2018-12-14 18:35:31 +01:00
4701341c0c ensure WSL compatibility 2018-12-13 16:50:32 +01:00
d5d347721a 2.0.11 2018-11-26 17:55:16 +01:00
6a047d6333 fix(core): update 2018-11-26 17:55:15 +01:00
6e7b4dd18e 2.0.10 2018-11-26 17:46:32 +01:00
debc5f1524 fix(core): update 2018-11-26 17:46:31 +01:00
8d03561762 2.0.9 2018-11-26 17:45:59 +01:00
f516a6e753 fix(core): update 2018-11-26 17:45:58 +01:00
1c4f6a8bf9 2.0.8 2018-10-28 19:18:42 +01:00
4fe3775904 fix(child processes): now run detached 2018-10-28 19:18:42 +01:00
8 changed files with 68 additions and 58 deletions

View File

@ -26,6 +26,7 @@ mirror:
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
@ -36,21 +37,11 @@ snyk:
# ====================
# test stage
# ====================
testLEGACY:
stage: test
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
@ -62,6 +53,7 @@ testLTS:
testSTABLE:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
@ -118,6 +110,7 @@ pages:
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags:
@ -130,13 +123,3 @@ pages:
paths:
- public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

View File

@ -1,6 +1,7 @@
{
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
"npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org"
}
}

14
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartshell",
"version": "2.0.7",
"version": "2.0.13",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -210,9 +210,9 @@
}
},
"@types/node": {
"version": "10.12.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz",
"integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==",
"version": "10.12.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.10.tgz",
"integrity": "sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w==",
"dev": true
},
"@types/vinyl": {
@ -963,9 +963,9 @@
}
},
"tslint-config-prettier": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.15.0.tgz",
"integrity": "sha512-06CgrHJxJmNYVgsmeMoa1KXzQRoOdvfkqnJth6XUkNeOz707qxN0WfxfhYwhL5kXHHbYJRby2bqAPKwThlZPhw==",
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.16.0.tgz",
"integrity": "sha512-zu6RAcpBtqdvhT6KpBh9kRPYATjOf9BnRi718kNqVKFjEgSE4rFrPprFju1YJrkOa3RbtbWI1ZSuLd2NBX1MDw==",
"dev": true
},
"tsutils": {

View File

@ -1,7 +1,7 @@
{
"name": "@pushrocks/smartshell",
"private": false,
"version": "2.0.7",
"version": "2.0.13",
"description": "shell actions designed as promises",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
@ -28,9 +28,9 @@
"@gitzone/tsrun": "^1.1.13",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.12.0",
"@types/node": "^10.12.10",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
"tslint-config-prettier": "^1.16.0"
},
"dependencies": {
"@pushrocks/smartpromise": "^2.0.5",

View File

@ -1,4 +1,4 @@
export type TExecutor = "sh" | "bash";
export type TExecutor = 'sh' | 'bash';
export interface IShellEnvContructorOptions {
executor: TExecutor;
@ -19,9 +19,7 @@ export class ShellEnv {
// add sourcefiles
if (optionsArg.sourceFilePaths) {
this.sourceFileArray = this.sourceFileArray.concat(
optionsArg.sourceFilePaths
);
this.sourceFileArray = this.sourceFileArray.concat(optionsArg.sourceFilePaths);
}
// add pathDirectories
@ -35,13 +33,26 @@ export class ShellEnv {
*/
private _setPath(commandStringArg): string {
let commandResult = commandStringArg;
let commandPath = process.env.PATH;
let commandPaths: string[] = [];
commandPaths = commandPaths.concat(process.env.PATH.split(':'));
if (process.env.SMARTSHELL_PATH) {
commandPath = `${commandPath}:${process.env.SMARTSHELL_PATH}`;
commandPaths = commandPaths.concat(process.env.SMARTSHELL_PATH.split(':'));
}
commandResult = `PATH=${
commandPath
} && ${commandStringArg}`;
// lets filter for unwanted paths
// Windows WSL
commandPaths = commandPaths.filter(commandPathArg => {
const filterResult =
!commandPathArg.startsWith('/mnt/c/') &&
!commandPathArg.startsWith('Files/1E') &&
!commandPathArg.includes(' ');
if (!filterResult) {
// console.log(`${commandPathArg} will be filtered!`);
}
return filterResult;
});
commandResult = `PATH=${commandPaths.join(':')} && ${commandStringArg}`;
return commandResult;
}
@ -63,13 +74,22 @@ export class ShellEnv {
}
createEnvExecString(commandArg): string {
let commandResult = ''
if (this.executor === "bash") {
let sourceString = "";
for (let sourceFilePath of this.sourceFileArray) {
sourceString = sourceString + `source ${sourceFilePath} && `;
}
commandResult = `bash -c '${sourceString} ${commandArg}'`;
let commandResult = '';
let sourceString = '';
switch (this.executor) {
case 'bash':
for (let sourceFilePath of this.sourceFileArray) {
sourceString = sourceString + `source ${sourceFilePath} && `;
}
commandResult = `bash -c '${sourceString}${commandArg}'`;
break;
case 'sh':
for (let sourceFilePath of this.sourceFileArray) {
sourceString = sourceString + `source ${sourceFilePath} && `;
}
commandResult = `${sourceString}${commandArg}`;
break;
}
commandResult = this._setPath(commandResult);
return commandResult;

View File

@ -13,13 +13,7 @@ export class ShellLog {
*/
logToConsole(dataArg: string | Buffer): void {
// make sure we have the data as string
const dataString: string = (() => {
if (Buffer.isBuffer(dataArg)) {
return dataArg.toString();
}
return dataArg;
})();
console.log(dataString);
process.stdout.write(dataArg);
}
/**

View File

@ -21,6 +21,7 @@ export interface IExecResult {
export interface IExecResultStreaming {
childProcess: cp.ChildProcess;
finalPromise: Promise<IExecResult>;
kill: () => void;
}
// -- SmartShell --
@ -29,7 +30,7 @@ export class Smartshell {
constructor(optionsArg: IShellEnvContructorOptions) {
this.shellEnv = new ShellEnv(optionsArg);
};
}
/**
* executes a given command async
@ -70,7 +71,11 @@ export class Smartshell {
if (streamingArg) {
done.resolve({
childProcess: execChildProcess,
finalPromise: childProcessEnded.promise
finalPromise: childProcessEnded.promise,
kill: () => {
// this notation with the - kills the whole process group
process.kill(-execChildProcess.pid);
}
});
}

View File

@ -4,7 +4,14 @@
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}