Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
e981ca6bdd | |||
2853a48708 | |||
389f8f4a52 | |||
c1a537f052 | |||
4701341c0c | |||
d5d347721a | |||
6a047d6333 | |||
6e7b4dd18e | |||
debc5f1524 | |||
8d03561762 | |||
f516a6e753 | |||
1c4f6a8bf9 | |||
4fe3775904 |
@ -26,6 +26,7 @@ mirror:
|
|||||||
snyk:
|
snyk:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
- npmci command npm install -g snyk
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command snyk test
|
||||||
@ -36,21 +37,11 @@ snyk:
|
|||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# 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:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install lts
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
@ -62,6 +53,7 @@ testLTS:
|
|||||||
testSTABLE:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
@ -118,6 +110,7 @@ pages:
|
|||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci command npm install -g typedoc typescript
|
||||||
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||||
tags:
|
tags:
|
||||||
@ -130,13 +123,3 @@ pages:
|
|||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
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
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public",
|
||||||
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
}
|
}
|
||||||
}
|
}
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartshell",
|
"name": "@pushrocks/smartshell",
|
||||||
"version": "2.0.7",
|
"version": "2.0.13",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -210,9 +210,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "10.12.0",
|
"version": "10.12.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.10.tgz",
|
||||||
"integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==",
|
"integrity": "sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/vinyl": {
|
"@types/vinyl": {
|
||||||
@ -963,9 +963,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tslint-config-prettier": {
|
"tslint-config-prettier": {
|
||||||
"version": "1.15.0",
|
"version": "1.16.0",
|
||||||
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.15.0.tgz",
|
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.16.0.tgz",
|
||||||
"integrity": "sha512-06CgrHJxJmNYVgsmeMoa1KXzQRoOdvfkqnJth6XUkNeOz707qxN0WfxfhYwhL5kXHHbYJRby2bqAPKwThlZPhw==",
|
"integrity": "sha512-zu6RAcpBtqdvhT6KpBh9kRPYATjOf9BnRi718kNqVKFjEgSE4rFrPprFju1YJrkOa3RbtbWI1ZSuLd2NBX1MDw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"tsutils": {
|
"tsutils": {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartshell",
|
"name": "@pushrocks/smartshell",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "2.0.7",
|
"version": "2.0.13",
|
||||||
"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",
|
||||||
@ -28,9 +28,9 @@
|
|||||||
"@gitzone/tsrun": "^1.1.13",
|
"@gitzone/tsrun": "^1.1.13",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.15",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
"@types/node": "^10.12.0",
|
"@types/node": "^10.12.10",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.16.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export type TExecutor = "sh" | "bash";
|
export type TExecutor = 'sh' | 'bash';
|
||||||
|
|
||||||
export interface IShellEnvContructorOptions {
|
export interface IShellEnvContructorOptions {
|
||||||
executor: TExecutor;
|
executor: TExecutor;
|
||||||
@ -19,9 +19,7 @@ export class ShellEnv {
|
|||||||
|
|
||||||
// add sourcefiles
|
// add sourcefiles
|
||||||
if (optionsArg.sourceFilePaths) {
|
if (optionsArg.sourceFilePaths) {
|
||||||
this.sourceFileArray = this.sourceFileArray.concat(
|
this.sourceFileArray = this.sourceFileArray.concat(optionsArg.sourceFilePaths);
|
||||||
optionsArg.sourceFilePaths
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add pathDirectories
|
// add pathDirectories
|
||||||
@ -35,13 +33,26 @@ export class ShellEnv {
|
|||||||
*/
|
*/
|
||||||
private _setPath(commandStringArg): string {
|
private _setPath(commandStringArg): string {
|
||||||
let commandResult = commandStringArg;
|
let commandResult = commandStringArg;
|
||||||
let commandPath = process.env.PATH;
|
let commandPaths: string[] = [];
|
||||||
|
commandPaths = commandPaths.concat(process.env.PATH.split(':'));
|
||||||
if (process.env.SMARTSHELL_PATH) {
|
if (process.env.SMARTSHELL_PATH) {
|
||||||
commandPath = `${commandPath}:${process.env.SMARTSHELL_PATH}`;
|
commandPaths = commandPaths.concat(process.env.SMARTSHELL_PATH.split(':'));
|
||||||
}
|
}
|
||||||
commandResult = `PATH=${
|
|
||||||
commandPath
|
// lets filter for unwanted paths
|
||||||
} && ${commandStringArg}`;
|
// 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;
|
return commandResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,13 +74,22 @@ export class ShellEnv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createEnvExecString(commandArg): string {
|
createEnvExecString(commandArg): string {
|
||||||
let commandResult = ''
|
let commandResult = '';
|
||||||
if (this.executor === "bash") {
|
let sourceString = '';
|
||||||
let sourceString = "";
|
|
||||||
for (let sourceFilePath of this.sourceFileArray) {
|
switch (this.executor) {
|
||||||
sourceString = sourceString + `source ${sourceFilePath} && `;
|
case 'bash':
|
||||||
}
|
for (let sourceFilePath of this.sourceFileArray) {
|
||||||
commandResult = `bash -c '${sourceString} ${commandArg}'`;
|
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);
|
commandResult = this._setPath(commandResult);
|
||||||
return commandResult;
|
return commandResult;
|
||||||
|
@ -13,13 +13,7 @@ export class ShellLog {
|
|||||||
*/
|
*/
|
||||||
logToConsole(dataArg: string | Buffer): void {
|
logToConsole(dataArg: string | Buffer): void {
|
||||||
// make sure we have the data as string
|
// make sure we have the data as string
|
||||||
const dataString: string = (() => {
|
process.stdout.write(dataArg);
|
||||||
if (Buffer.isBuffer(dataArg)) {
|
|
||||||
return dataArg.toString();
|
|
||||||
}
|
|
||||||
return dataArg;
|
|
||||||
})();
|
|
||||||
console.log(dataString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ export interface IExecResult {
|
|||||||
export interface IExecResultStreaming {
|
export interface IExecResultStreaming {
|
||||||
childProcess: cp.ChildProcess;
|
childProcess: cp.ChildProcess;
|
||||||
finalPromise: Promise<IExecResult>;
|
finalPromise: Promise<IExecResult>;
|
||||||
|
kill: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- SmartShell --
|
// -- SmartShell --
|
||||||
@ -29,7 +30,7 @@ export class Smartshell {
|
|||||||
|
|
||||||
constructor(optionsArg: IShellEnvContructorOptions) {
|
constructor(optionsArg: IShellEnvContructorOptions) {
|
||||||
this.shellEnv = new ShellEnv(optionsArg);
|
this.shellEnv = new ShellEnv(optionsArg);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* executes a given command async
|
* executes a given command async
|
||||||
@ -70,7 +71,11 @@ export class Smartshell {
|
|||||||
if (streamingArg) {
|
if (streamingArg) {
|
||||||
done.resolve({
|
done.resolve({
|
||||||
childProcess: execChildProcess,
|
childProcess: execChildProcess,
|
||||||
finalPromise: childProcessEnded.promise
|
finalPromise: childProcessEnded.promise,
|
||||||
|
kill: () => {
|
||||||
|
// this notation with the - kills the whole process group
|
||||||
|
process.kill(-execChildProcess.pid);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,14 @@
|
|||||||
"semicolon": [true, "always"],
|
"semicolon": [true, "always"],
|
||||||
"no-console": false,
|
"no-console": false,
|
||||||
"ordered-imports": false,
|
"ordered-imports": false,
|
||||||
"object-literal-sort-keys": false
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"defaultSeverity": "warning"
|
"defaultSeverity": "warning"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user