tnp-core 16.6.24 → 16.6.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,7 +55,7 @@ export declare namespace CoreModels {
55
55
  * Use big buffer for big webpack logs
56
56
  */
57
57
  biggerBuffer?: boolean;
58
- exitOnError?: boolean;
58
+ askToTryAgainOnError?: boolean;
59
59
  exitOnErrorCallback?: (code: number) => void;
60
60
  /**
61
61
  * From displaying in console
@@ -63,6 +63,7 @@ export declare namespace CoreModels {
63
63
  hideOutput?: {
64
64
  stdout?: boolean;
65
65
  stderr?: boolean;
66
+ acceptAllExitCodeAsSuccess?: boolean;
66
67
  };
67
68
  }
68
69
  /**
@@ -68,6 +68,11 @@ export declare class HelpersCore extends HelpersMessages {
68
68
  run(command: string, options?: CoreModels.RunOptions): {
69
69
  async(detach?: boolean, mockFun?: (stdoutCallback: (dataForStdout: any) => any, stdErrcCallback: (dataForStder: any) => any, shouldProcesBeDead?: () => boolean) => Promise<number> | number): any;
70
70
  };
71
+ questionYesNo(message: string, callbackTrue?: () => any, callbackFalse?: () => any, defaultValue?: boolean,
72
+ /**
73
+ * in non interactive mode
74
+ */
75
+ mustAnswerQuestion?: boolean): Promise<any>;
71
76
  /**
72
77
  * Quick fix for object values
73
78
  * @deprecated
@@ -166,7 +166,7 @@
166
166
  "angular-material-css-vars": "5.0.2",
167
167
  "angular-resize-event": "3.2.0",
168
168
  "animate.css": "4.1.1 ",
169
- "any-project-cli": "~16.5.18",
169
+ "any-project-cli": "~16.5.20",
170
170
  "background-worker-process": "~16.5.15",
171
171
  "base32": "0.0.7",
172
172
  "bcryptjs": "2.4.3",
@@ -209,7 +209,7 @@
209
209
  "file-saver": "2.0.5",
210
210
  "file-type": "18.5.0",
211
211
  "firedev": "^16",
212
- "firedev-crud": "~16.5.15",
212
+ "firedev-crud": "~16.5.60",
213
213
  "firedev-crud-deamon": "~16.5.14",
214
214
  "firedev-ports": "~16.5.15",
215
215
  "firedev-storage": "~16.5.13",
@@ -229,7 +229,7 @@
229
229
  "image-focus": "1.2.1",
230
230
  "immer": "10.0.2",
231
231
  "immutable": "4.3.0",
232
- "incremental-compiler": "~16.5.27",
232
+ "incremental-compiler": "~16.5.29",
233
233
  "inquirer": "7.3.3",
234
234
  "inquirer-autocomplete-prompt": "1.3.0",
235
235
  "isomorphic-region-loader": "~16.5.14",
@@ -244,7 +244,7 @@
244
244
  "jscodeshift": "0.6.3",
245
245
  "json-stringify-safe": "5.0.1",
246
246
  "json10": "~16.5.13",
247
- "json10-writer": "~16.5.18",
247
+ "json10-writer": "~16.5.20",
248
248
  "json5-writer": "0.2.0",
249
249
  "jszip": "3.10.1",
250
250
  "karma-cli": "1.0.1",
@@ -264,7 +264,7 @@
264
264
  "ng-lock": "16.0.1",
265
265
  "ng-packagr": "16.0.1",
266
266
  "ng-talkback": "~16.5.14",
267
- "ng2-logger": "~16.5.20",
267
+ "ng2-logger": "~16.5.22",
268
268
  "ng2-rest": "~16.5.13",
269
269
  "ngx-ace-wrapper": "14.0.0",
270
270
  "ngx-editor": "15.3.0",
@@ -320,11 +320,11 @@
320
320
  "task.js": "0.1.5",
321
321
  "threads": "1.7.0",
322
322
  "tnp-cli": "~16.5.13",
323
- "tnp-config": "~16.5.29",
324
- "tnp-core": "~16.6.23",
323
+ "tnp-config": "~16.5.31",
324
+ "tnp-core": "~16.6.26",
325
325
  "tnp-db": "~16.5.13",
326
- "tnp-helpers": "~16.5.20",
327
- "tnp-models": "~16.5.18",
326
+ "tnp-helpers": "~16.5.22",
327
+ "tnp-models": "~16.5.20",
328
328
  "ts-debug": "1.3.0",
329
329
  "ts-loader": "2.3.1",
330
330
  "ts-node": "10.9.1",
@@ -333,7 +333,7 @@
333
333
  "turndown": "7.1.2",
334
334
  "typeorm": "~0.3.10",
335
335
  "typescript": "~5.0.2",
336
- "typescript-class-helpers": "~16.5.19",
336
+ "typescript-class-helpers": "~16.5.21",
337
337
  "typescript-formatter": "~7.2.2",
338
338
  "underscore": "1.9.1",
339
339
  "uuid": "8.3.2",
@@ -347,6 +347,6 @@
347
347
  "license": "MIT",
348
348
  "private": false,
349
349
  "name": "tnp-core",
350
- "version": "16.6.24",
351
- "lastBuildTagHash": "ba1c274f6f81ee50836f407c6bc83404acd8f520"
350
+ "version": "16.6.28",
351
+ "lastBuildTagHash": "63d4fd669950ab45e288a3ac067f5964a16943b7"
352
352
  }
@@ -55,7 +55,7 @@ export declare namespace CoreModels {
55
55
  * Use big buffer for big webpack logs
56
56
  */
57
57
  biggerBuffer?: boolean;
58
- exitOnError?: boolean;
58
+ askToTryAgainOnError?: boolean;
59
59
  exitOnErrorCallback?: (code: number) => void;
60
60
  /**
61
61
  * From displaying in console
@@ -63,6 +63,7 @@ export declare namespace CoreModels {
63
63
  hideOutput?: {
64
64
  stdout?: boolean;
65
65
  stderr?: boolean;
66
+ acceptAllExitCodeAsSuccess?: boolean;
66
67
  };
67
68
  }
68
69
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"core-models.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA,IAAiB,UAAU,CAgV1B;AAhVD,WAAiB,UAAU;IA4HzB,YAAY;IAEZ,mCAAmC;IAEnC,2FAA2F;IAC9E,oBAAS,GAAG;QACvB,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE,8BAA8B;QACtC,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,oBAAoB;QAC5B,OAAO,EAAE,yEAAyE;QAClF,MAAM,EAAE,+BAA+B;QACvC,OAAO,EAAE,sBAAsB;QAC/B,KAAK,EAAE,kBAAkB;QACzB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B;QACjC,MAAM,EAAE,0BAA0B;QAClC,OAAO,EAAE,mEAAmE;QAC5E,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE,iCAAiC;QACzC,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE,YAAY;QACpB,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,6BAA6B;KAC5B,CAAC;IAaE,0BAAe,GAAG;QAC7B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM;QACzC,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO;KAChC,CAAA;IAGH,uBAAY,GAAG,WAAA,SAAS,CAAC;IAoBrC,CAAC;IAsFF,YAAY;AAKd,CAAC,EAjVgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAiV1B"}
package/lib/helpers.d.ts CHANGED
@@ -103,11 +103,16 @@ export declare class HelpersCore extends HelpersMessages {
103
103
  asyncAsPromise(): any;
104
104
  unitlOutputContains(stdoutMsg: string | string[], stderMsg?: string | string[], timeout?: number): Promise<any>;
105
105
  };
106
+ questionYesNo(message: string, callbackTrue?: () => any, callbackFalse?: () => any, defaultValue?: boolean,
107
+ /**
108
+ * in non interactive mode
109
+ */
110
+ mustAnswerQuestion?: boolean): Promise<boolean>;
106
111
  getStdio(options?: CoreModels.RunOptions): any;
107
112
  runSyncIn(command: string, options?: CoreModels.RunOptions): string;
108
113
  runAsyncIn(command: string, options?: CoreModels.RunOptions): child_process.ChildProcess;
109
114
  logProc(proc: child_process.ChildProcess, output: boolean, stdio: any, outputLineReplace: (outputLine: string) => string, prefix: string, extractFromLine?: (string | Function)[]): child_process.ChildProcess;
110
- execute(command: string, cwd: string, options?: CoreModels.ExecuteOptions): Promise<unknown>;
115
+ execute(command: string, cwd: string, options?: Omit<CoreModels.ExecuteOptions, 'tryAgainWhenFailAfter'>): Promise<void>;
111
116
  /**
112
117
  * @deprecated
113
118
  */
package/lib/helpers.js CHANGED
@@ -13,6 +13,7 @@ var core_models_1 = require("./core-models");
13
13
  var encoding = 'utf8';
14
14
  //#region @backend
15
15
  var forceTrace = !global.hideLog;
16
+ var prompts = require('prompts');
16
17
  //#endregion
17
18
  var WEBSQL_PROC_MOCK_PROCESSES_PID = {};
18
19
  var WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
@@ -924,6 +925,54 @@ var HelpersCore = /** @class */ (function (_super) {
924
925
  };
925
926
  };
926
927
  //#endregion
928
+ HelpersCore.prototype.questionYesNo = function (message, callbackTrue, callbackFalse, defaultValue,
929
+ /**
930
+ * in non interactive mode
931
+ */
932
+ mustAnswerQuestion) {
933
+ if (defaultValue === void 0) { defaultValue = true; }
934
+ if (mustAnswerQuestion === void 0) { mustAnswerQuestion = false; }
935
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
936
+ var response;
937
+ return tslib_1.__generator(this, function (_a) {
938
+ switch (_a.label) {
939
+ case 0:
940
+ response = {
941
+ value: defaultValue
942
+ };
943
+ if (!(global.tnpNonInteractive && !mustAnswerQuestion)) return [3 /*break*/, 1];
944
+ index_1.Helpers.info("".concat(message, " - AUTORESPONSE: ").concat(defaultValue ? 'YES' : 'NO'));
945
+ return [3 /*break*/, 3];
946
+ case 1: return [4 /*yield*/, prompts({
947
+ type: 'toggle',
948
+ name: 'value',
949
+ message: message,
950
+ initial: defaultValue,
951
+ active: 'yes',
952
+ inactive: 'no'
953
+ })];
954
+ case 2:
955
+ response = _a.sent();
956
+ _a.label = 3;
957
+ case 3:
958
+ if (!response.value) return [3 /*break*/, 6];
959
+ if (!callbackTrue) return [3 /*break*/, 5];
960
+ return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: callbackTrue })];
961
+ case 4:
962
+ _a.sent();
963
+ _a.label = 5;
964
+ case 5: return [3 /*break*/, 8];
965
+ case 6:
966
+ if (!callbackFalse) return [3 /*break*/, 8];
967
+ return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: callbackFalse })];
968
+ case 7:
969
+ _a.sent();
970
+ _a.label = 8;
971
+ case 8: return [2 /*return*/, response.value];
972
+ }
973
+ });
974
+ });
975
+ };
927
976
  //#region methods / get stdio
928
977
  //#region @backend
929
978
  HelpersCore.prototype.getStdio = function (options) {
@@ -1058,140 +1107,181 @@ var HelpersCore = /** @class */ (function (_super) {
1058
1107
  return proc;
1059
1108
  };
1060
1109
  HelpersCore.prototype.execute = function (command, cwd, options) {
1061
- var _this = this;
1062
- var _a = options || {}, hideOutput = _a.hideOutput, resolvePromiseMsg = _a.resolvePromiseMsg, outputLineReplace = _a.outputLineReplace, prefix = _a.prefix, extractFromLine = _a.extractFromLine, exitOnError = _a.exitOnError, exitOnErrorCallback = _a.exitOnErrorCallback;
1063
- command = index_1.Helpers._fixCommand(command);
1064
- var childProcess = core_imports_1.child_process.exec(command, { cwd: cwd });
1065
- // let {
1066
- // stderMsgForPromiseResolve,
1067
- // stdoutMsgForPromiseResolve
1068
- // } = resolvePromiseMsg || {};
1069
- // processes.push(proc);
1070
- if (!resolvePromiseMsg) {
1071
- resolvePromiseMsg = {};
1072
- }
1073
- if (!hideOutput) {
1074
- hideOutput = {};
1075
- }
1076
- var isResolved = false;
1077
- if (core_imports_1._.isString(resolvePromiseMsg.stdout)) {
1078
- resolvePromiseMsg.stdout = [resolvePromiseMsg.stdout];
1079
- }
1080
- if (core_imports_1._.isString(resolvePromiseMsg.stderr)) {
1081
- resolvePromiseMsg.stderr = [resolvePromiseMsg.stderr];
1082
- }
1083
- return new Promise(function (resolve, reject) {
1084
- // let stdio = [0,1,2]
1085
- // @ts-ignore
1086
- childProcess.stdout.on('data', function (rawData) {
1087
- var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1088
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1089
- outputLineReplace, prefix, extractFromLine);
1090
- // @ts-ignore
1091
- if (!hideOutput.stdout) {
1092
- process.stdout.write(data);
1093
- }
1094
- // @ts-ignore
1095
- if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stdout)) { // @ts-ignore
1096
- for (var index = 0; index < resolvePromiseMsg.stdout.length; index++) { // @ts-ignore
1097
- var m = resolvePromiseMsg.stdout[index];
1098
- if ((data.search(m) !== -1)) {
1099
- // Helpers.info(`[unitlOutputContains] Move to next step...`)
1100
- isResolved = true;
1101
- resolve(void 0);
1102
- break;
1110
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1111
+ var _a, hideOutput, resolvePromiseMsg, outputLineReplace, prefix, extractFromLine, exitOnErrorCallback, askToTryAgainOnError, childProcess, isResolved, handlProc, error_1;
1112
+ var _this = this;
1113
+ return tslib_1.__generator(this, function (_b) {
1114
+ switch (_b.label) {
1115
+ case 0:
1116
+ _a = options || {}, hideOutput = _a.hideOutput, resolvePromiseMsg = _a.resolvePromiseMsg, outputLineReplace = _a.outputLineReplace, prefix = _a.prefix, extractFromLine = _a.extractFromLine, exitOnErrorCallback = _a.exitOnErrorCallback, askToTryAgainOnError = _a.askToTryAgainOnError;
1117
+ //#endregion
1118
+ command = index_1.Helpers._fixCommand(command);
1119
+ // let {
1120
+ // stderMsgForPromiseResolve,
1121
+ // stdoutMsgForPromiseResolve
1122
+ // } = resolvePromiseMsg || {};
1123
+ // processes.push(proc);
1124
+ if (!resolvePromiseMsg) {
1125
+ resolvePromiseMsg = {};
1103
1126
  }
1104
- }
1105
- }
1106
- // @ts-ignore
1107
- if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) { // @ts-ignore
1108
- for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) { // @ts-ignore
1109
- var rejectm = resolvePromiseMsg.stderr[index];
1110
- if ((data.search(rejectm) !== -1)) {
1111
- // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1112
- isResolved = true;
1113
- reject();
1114
- childProcess.kill('SIGINT');
1115
- break;
1127
+ if (!hideOutput) {
1128
+ hideOutput = {};
1116
1129
  }
1117
- }
1118
- }
1119
- // console.log(data.toString());
1120
- });
1121
- childProcess.on('exit', function (code) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1122
- var error_1;
1123
- return tslib_1.__generator(this, function (_a) {
1124
- switch (_a.label) {
1125
- case 0:
1126
- if (!(exitOnError && code !== 0)) return [3 /*break*/, 5];
1127
- if (!core_imports_1._.isFunction(exitOnErrorCallback)) return [3 /*break*/, 4];
1128
- _a.label = 1;
1129
- case 1:
1130
- _a.trys.push([1, 3, , 4]);
1131
- return [4 /*yield*/, this.runSyncOrAsync({
1132
- functionFn: exitOnErrorCallback,
1133
- arrayOfParams: [code],
1134
- })];
1135
- case 2:
1136
- _a.sent();
1137
- return [3 /*break*/, 4];
1138
- case 3:
1139
- error_1 = _a.sent();
1140
- return [3 /*break*/, 4];
1141
- case 4:
1142
- // @ts-ignore
1143
- process.exit(code);
1144
- _a.label = 5;
1145
- case 5:
1146
- resolve(void 0);
1147
- return [2 /*return*/];
1148
- }
1149
- });
1150
- }); });
1151
- // @ts-ignore
1152
- childProcess.stdout.on('error', function (rawData) {
1153
- var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1154
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1155
- outputLineReplace, prefix, extractFromLine);
1156
- // @ts-ignore
1157
- if (!hideOutput.stdout) {
1158
- process.stdout.write(JSON.stringify(data));
1159
- }
1160
- // console.log(data);
1161
- });
1162
- // @ts-ignore
1163
- childProcess.stderr.on('data', function (rawData) {
1164
- var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1165
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1166
- outputLineReplace, prefix, extractFromLine);
1167
- // @ts-ignore
1168
- if (!hideOutput.stderr) {
1169
- process.stderr.write(data);
1170
- }
1171
- // @ts-ignore
1172
- if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) { // @ts-ignore
1173
- for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) { // @ts-ignore
1174
- var rejectm = resolvePromiseMsg.stderr[index];
1175
- if ((data.search(rejectm) !== -1)) {
1176
- // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1177
- isResolved = true;
1178
- reject();
1179
- childProcess.kill('SIGINT');
1180
- break;
1130
+ isResolved = false;
1131
+ if (core_imports_1._.isString(resolvePromiseMsg.stdout)) {
1132
+ resolvePromiseMsg.stdout = [resolvePromiseMsg.stdout];
1181
1133
  }
1182
- }
1183
- }
1184
- });
1185
- // @ts-ignore
1186
- childProcess.stderr.on('error', function (rawData) {
1187
- var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1188
- data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1189
- outputLineReplace, prefix, extractFromLine);
1190
- // @ts-ignore
1191
- if (!hideOutput.stderr) {
1192
- process.stderr.write(JSON.stringify(data));
1134
+ if (core_imports_1._.isString(resolvePromiseMsg.stderr)) {
1135
+ resolvePromiseMsg.stderr = [resolvePromiseMsg.stderr];
1136
+ }
1137
+ handlProc = function (proc) {
1138
+ return new Promise(function (resolve, reject) {
1139
+ //#region handle stdout data
1140
+ proc.stdout.on('data', function (rawData) {
1141
+ var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1142
+ data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1143
+ outputLineReplace, prefix, extractFromLine);
1144
+ if (!hideOutput.stdout) {
1145
+ process.stdout.write(data);
1146
+ }
1147
+ if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stdout)) { // @ts-ignore
1148
+ for (var index = 0; index < resolvePromiseMsg.stdout.length; index++) { // @ts-ignore
1149
+ var m = resolvePromiseMsg.stdout[index];
1150
+ if ((data.search(m) !== -1)) {
1151
+ // Helpers.info(`[unitlOutputContains] Move to next step...`)
1152
+ isResolved = true;
1153
+ resolve(void 0);
1154
+ break;
1155
+ }
1156
+ }
1157
+ }
1158
+ if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) { // @ts-ignore
1159
+ for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) { // @ts-ignore
1160
+ var rejectm = resolvePromiseMsg.stderr[index];
1161
+ if ((data.search(rejectm) !== -1)) {
1162
+ // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1163
+ isResolved = true;
1164
+ reject();
1165
+ proc.kill('SIGINT');
1166
+ break;
1167
+ }
1168
+ }
1169
+ }
1170
+ });
1171
+ //#endregion
1172
+ //#region handle exit process
1173
+ proc.on('exit', function (code) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1174
+ var error_2;
1175
+ return tslib_1.__generator(this, function (_a) {
1176
+ switch (_a.label) {
1177
+ case 0:
1178
+ if (!hideOutput.acceptAllExitCodeAsSuccess) return [3 /*break*/, 1];
1179
+ resolve(void 0);
1180
+ return [3 /*break*/, 9];
1181
+ case 1:
1182
+ if (!(code !== 0)) return [3 /*break*/, 8];
1183
+ if (!core_imports_1._.isFunction(exitOnErrorCallback)) return [3 /*break*/, 6];
1184
+ _a.label = 2;
1185
+ case 2:
1186
+ _a.trys.push([2, 4, , 5]);
1187
+ return [4 /*yield*/, this.runSyncOrAsync({
1188
+ functionFn: exitOnErrorCallback,
1189
+ arrayOfParams: [code],
1190
+ })];
1191
+ case 3:
1192
+ _a.sent();
1193
+ reject("Command failed with code=".concat(code));
1194
+ return [3 /*break*/, 5];
1195
+ case 4:
1196
+ error_2 = _a.sent();
1197
+ reject(error_2);
1198
+ return [3 /*break*/, 5];
1199
+ case 5: return [3 /*break*/, 7];
1200
+ case 6:
1201
+ reject("Command failed with code=".concat(code));
1202
+ _a.label = 7;
1203
+ case 7: return [3 /*break*/, 9];
1204
+ case 8:
1205
+ resolve(void 0);
1206
+ _a.label = 9;
1207
+ case 9: return [2 /*return*/];
1208
+ }
1209
+ });
1210
+ }); });
1211
+ //#endregion
1212
+ //#region handle stdout error
1213
+ proc.stdout.on('error', function (rawData) {
1214
+ var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1215
+ data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1216
+ outputLineReplace, prefix, extractFromLine);
1217
+ if (!hideOutput.stdout) {
1218
+ process.stdout.write(JSON.stringify(data));
1219
+ }
1220
+ // console.log(data);
1221
+ });
1222
+ //#endregion
1223
+ //#region handle stder data
1224
+ proc.stderr.on('data', function (rawData) {
1225
+ var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1226
+ data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1227
+ outputLineReplace, prefix, extractFromLine);
1228
+ if (!hideOutput.stderr) {
1229
+ process.stderr.write(data);
1230
+ }
1231
+ if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) { // @ts-ignore
1232
+ for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) { // @ts-ignore
1233
+ var rejectm = resolvePromiseMsg.stderr[index];
1234
+ if ((data.search(rejectm) !== -1)) {
1235
+ // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1236
+ isResolved = true;
1237
+ reject();
1238
+ proc.kill('SIGINT');
1239
+ break;
1240
+ }
1241
+ }
1242
+ }
1243
+ });
1244
+ //#endregion
1245
+ //#region handle stder error
1246
+ proc.stderr.on('error', function (rawData) {
1247
+ var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1248
+ data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1249
+ outputLineReplace, prefix, extractFromLine);
1250
+ // @ts-ignore
1251
+ if (!hideOutput.stderr) {
1252
+ process.stderr.write(JSON.stringify(data));
1253
+ }
1254
+ // console.log(data);
1255
+ });
1256
+ //#endregion
1257
+ });
1258
+ };
1259
+ _b.label = 1;
1260
+ case 1:
1261
+ if (!true) return [3 /*break*/, 9];
1262
+ childProcess = core_imports_1.child_process.exec(command, { cwd: cwd });
1263
+ _b.label = 2;
1264
+ case 2:
1265
+ _b.trys.push([2, 4, , 8]);
1266
+ return [4 /*yield*/, handlProc(childProcess)];
1267
+ case 3:
1268
+ _b.sent();
1269
+ return [3 /*break*/, 9];
1270
+ case 4:
1271
+ error_1 = _b.sent();
1272
+ index_1.Helpers.error("Command failed:\n\n".concat(command, "\n\nin location: ").concat(cwd, "\n\n "), true, true);
1273
+ if (!askToTryAgainOnError) return [3 /*break*/, 6];
1274
+ return [4 /*yield*/, index_1.Helpers.questionYesNo("Try again this command ?")];
1275
+ case 5:
1276
+ if (!(_b.sent())) {
1277
+ throw error_1;
1278
+ }
1279
+ return [3 /*break*/, 7];
1280
+ case 6: throw error_1;
1281
+ case 7: return [3 /*break*/, 8];
1282
+ case 8: return [3 /*break*/, 1];
1283
+ case 9: return [2 /*return*/];
1193
1284
  }
1194
- // console.log(data);
1195
1285
  });
1196
1286
  });
1197
1287
  };
@@ -1292,7 +1382,7 @@ var HelpersCore = /** @class */ (function (_super) {
1292
1382
  if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
1293
1383
  if (notTrim === void 0) { notTrim = false; }
1294
1384
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1295
- var fileContent, error_2;
1385
+ var fileContent, error_3;
1296
1386
  return tslib_1.__generator(this, function (_a) {
1297
1387
  switch (_a.label) {
1298
1388
  case 0:
@@ -1306,7 +1396,7 @@ var HelpersCore = /** @class */ (function (_super) {
1306
1396
  fileContent = index_1.Helpers.readFile(absoluteFilePath, defaultValueWhenNotExists, notTrim);
1307
1397
  return [2 /*return*/, fileContent];
1308
1398
  case 3:
1309
- error_2 = _a.sent();
1399
+ error_3 = _a.sent();
1310
1400
  index_1.Helpers.error("Not able to read locked file: ".concat(absoluteFilePath), true, true);
1311
1401
  return [4 /*yield*/, index_1.Helpers.wait(2)];
1312
1402
  case 4:
@@ -1402,7 +1492,6 @@ var HelpersCore = /** @class */ (function (_super) {
1402
1492
  function currentDate() {
1403
1493
  return "[".concat((0, core_imports_1.dateformat)(new Date(), 'HH:MM:ss'), "]");
1404
1494
  }
1405
- var error_3;
1406
1495
  return tslib_1.__generator(this, function (_a) {
1407
1496
  switch (_a.label) {
1408
1497
  case 0:
@@ -1410,22 +1499,12 @@ var HelpersCore = /** @class */ (function (_super) {
1410
1499
  index_1.Helpers.error("".concat(executionType, " wrapper: \"").concat(fn, "\" is not a function."));
1411
1500
  process.exit(1);
1412
1501
  }
1413
- _a.label = 1;
1414
- case 1:
1415
- _a.trys.push([1, 3, , 4]);
1416
1502
  index_1.Helpers.log("".concat(currentDate(), " ").concat(executionType, " \"").concat(taskName, "\" Started.."));
1417
1503
  return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: fn })];
1418
- case 2:
1504
+ case 1:
1419
1505
  _a.sent();
1420
1506
  index_1.Helpers.log("".concat(currentDate(), " ").concat(executionType, " \"").concat(taskName, "\" Done\u2713"));
1421
- return [3 /*break*/, 4];
1422
- case 3:
1423
- error_3 = _a.sent();
1424
- index_1.Helpers.error(core_imports_1.chalk.red(error_3), false, true);
1425
- index_1.Helpers.log("".concat(currentDate(), " ").concat(executionType, " ").concat(taskName, " ERROR"));
1426
- process.exit(1);
1427
- return [3 /*break*/, 4];
1428
- case 4: return [2 /*return*/];
1507
+ return [2 /*return*/];
1429
1508
  }
1430
1509
  });
1431
1510
  });