tnp-core 16.6.23 → 16.6.26

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,7 @@ 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): Promise<any>;
71
72
  /**
72
73
  * Quick fix for object values
73
74
  * @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.17",
169
+ "any-project-cli": "~16.5.19",
170
170
  "background-worker-process": "~16.5.15",
171
171
  "base32": "0.0.7",
172
172
  "bcryptjs": "2.4.3",
@@ -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.26",
232
+ "incremental-compiler": "~16.5.28",
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.17",
247
+ "json10-writer": "~16.5.19",
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.19",
267
+ "ng2-logger": "~16.5.21",
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.28",
324
- "tnp-core": "~16.6.22",
323
+ "tnp-config": "~16.5.30",
324
+ "tnp-core": "~16.6.24",
325
325
  "tnp-db": "~16.5.13",
326
- "tnp-helpers": "~16.5.19",
327
- "tnp-models": "~16.5.17",
326
+ "tnp-helpers": "~16.5.21",
327
+ "tnp-models": "~16.5.19",
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.18",
336
+ "typescript-class-helpers": "~16.5.20",
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.23",
351
- "lastBuildTagHash": "8bb66c74941f32aa56b5d120b684dded55857f0f"
350
+ "version": "16.6.26",
351
+ "lastBuildTagHash": "98171d6191814a2436743ef6b2b324ea016a7b58"
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,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,WAAW;QACnB,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,0BAA0B;QAClC,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,YAAY;QACpB,KAAK,EAAE,iBAAiB;QACxB,OAAO,EAAE,kBAAkB;QAC3B,SAAS,EAAE,qBAAqB;Q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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,12 @@ 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): Promise<boolean>;
106
107
  getStdio(options?: CoreModels.RunOptions): any;
107
108
  runSyncIn(command: string, options?: CoreModels.RunOptions): string;
108
109
  runAsyncIn(command: string, options?: CoreModels.RunOptions): child_process.ChildProcess;
109
110
  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>;
111
+ execute(command: string, cwd: string, options?: Omit<CoreModels.ExecuteOptions, 'tryAgainWhenFailAfter'>): Promise<void>;
111
112
  /**
112
113
  * @deprecated
113
114
  */
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,49 @@ var HelpersCore = /** @class */ (function (_super) {
924
925
  };
925
926
  };
926
927
  //#endregion
928
+ HelpersCore.prototype.questionYesNo = function (message, callbackTrue, callbackFalse, defaultValue) {
929
+ if (defaultValue === void 0) { defaultValue = true; }
930
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
931
+ var response;
932
+ return tslib_1.__generator(this, function (_a) {
933
+ switch (_a.label) {
934
+ case 0:
935
+ response = {
936
+ value: defaultValue
937
+ };
938
+ if (!global.tnpNonInteractive) return [3 /*break*/, 1];
939
+ index_1.Helpers.info("".concat(message, " - AUTORESPONSE: ").concat(defaultValue ? 'YES' : 'NO'));
940
+ return [3 /*break*/, 3];
941
+ case 1: return [4 /*yield*/, prompts({
942
+ type: 'toggle',
943
+ name: 'value',
944
+ message: message,
945
+ initial: defaultValue,
946
+ active: 'yes',
947
+ inactive: 'no'
948
+ })];
949
+ case 2:
950
+ response = _a.sent();
951
+ _a.label = 3;
952
+ case 3:
953
+ if (!response.value) return [3 /*break*/, 6];
954
+ if (!callbackTrue) return [3 /*break*/, 5];
955
+ return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: callbackTrue })];
956
+ case 4:
957
+ _a.sent();
958
+ _a.label = 5;
959
+ case 5: return [3 /*break*/, 8];
960
+ case 6:
961
+ if (!callbackFalse) return [3 /*break*/, 8];
962
+ return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: callbackFalse })];
963
+ case 7:
964
+ _a.sent();
965
+ _a.label = 8;
966
+ case 8: return [2 /*return*/, response.value];
967
+ }
968
+ });
969
+ });
970
+ };
927
971
  //#region methods / get stdio
928
972
  //#region @backend
929
973
  HelpersCore.prototype.getStdio = function (options) {
@@ -1058,140 +1102,181 @@ var HelpersCore = /** @class */ (function (_super) {
1058
1102
  return proc;
1059
1103
  };
1060
1104
  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;
1105
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1106
+ var _a, hideOutput, resolvePromiseMsg, outputLineReplace, prefix, extractFromLine, exitOnErrorCallback, askToTryAgainOnError, childProcess, isResolved, handlProc, error_1;
1107
+ var _this = this;
1108
+ return tslib_1.__generator(this, function (_b) {
1109
+ switch (_b.label) {
1110
+ case 0:
1111
+ _a = options || {}, hideOutput = _a.hideOutput, resolvePromiseMsg = _a.resolvePromiseMsg, outputLineReplace = _a.outputLineReplace, prefix = _a.prefix, extractFromLine = _a.extractFromLine, exitOnErrorCallback = _a.exitOnErrorCallback, askToTryAgainOnError = _a.askToTryAgainOnError;
1112
+ //#endregion
1113
+ command = index_1.Helpers._fixCommand(command);
1114
+ // let {
1115
+ // stderMsgForPromiseResolve,
1116
+ // stdoutMsgForPromiseResolve
1117
+ // } = resolvePromiseMsg || {};
1118
+ // processes.push(proc);
1119
+ if (!resolvePromiseMsg) {
1120
+ resolvePromiseMsg = {};
1103
1121
  }
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;
1122
+ if (!hideOutput) {
1123
+ hideOutput = {};
1116
1124
  }
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;
1125
+ isResolved = false;
1126
+ if (core_imports_1._.isString(resolvePromiseMsg.stdout)) {
1127
+ resolvePromiseMsg.stdout = [resolvePromiseMsg.stdout];
1181
1128
  }
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));
1129
+ if (core_imports_1._.isString(resolvePromiseMsg.stderr)) {
1130
+ resolvePromiseMsg.stderr = [resolvePromiseMsg.stderr];
1131
+ }
1132
+ handlProc = function (proc) {
1133
+ return new Promise(function (resolve, reject) {
1134
+ //#region handle stdout data
1135
+ proc.stdout.on('data', function (rawData) {
1136
+ var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1137
+ data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1138
+ outputLineReplace, prefix, extractFromLine);
1139
+ if (!hideOutput.stdout) {
1140
+ process.stdout.write(data);
1141
+ }
1142
+ if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stdout)) { // @ts-ignore
1143
+ for (var index = 0; index < resolvePromiseMsg.stdout.length; index++) { // @ts-ignore
1144
+ var m = resolvePromiseMsg.stdout[index];
1145
+ if ((data.search(m) !== -1)) {
1146
+ // Helpers.info(`[unitlOutputContains] Move to next step...`)
1147
+ isResolved = true;
1148
+ resolve(void 0);
1149
+ break;
1150
+ }
1151
+ }
1152
+ }
1153
+ if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) { // @ts-ignore
1154
+ for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) { // @ts-ignore
1155
+ var rejectm = resolvePromiseMsg.stderr[index];
1156
+ if ((data.search(rejectm) !== -1)) {
1157
+ // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1158
+ isResolved = true;
1159
+ reject();
1160
+ proc.kill('SIGINT');
1161
+ break;
1162
+ }
1163
+ }
1164
+ }
1165
+ });
1166
+ //#endregion
1167
+ //#region handle exit process
1168
+ proc.on('exit', function (code) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
1169
+ var error_2;
1170
+ return tslib_1.__generator(this, function (_a) {
1171
+ switch (_a.label) {
1172
+ case 0:
1173
+ if (!hideOutput.acceptAllExitCodeAsSuccess) return [3 /*break*/, 1];
1174
+ resolve(void 0);
1175
+ return [3 /*break*/, 9];
1176
+ case 1:
1177
+ if (!(code !== 0)) return [3 /*break*/, 8];
1178
+ if (!core_imports_1._.isFunction(exitOnErrorCallback)) return [3 /*break*/, 6];
1179
+ _a.label = 2;
1180
+ case 2:
1181
+ _a.trys.push([2, 4, , 5]);
1182
+ return [4 /*yield*/, this.runSyncOrAsync({
1183
+ functionFn: exitOnErrorCallback,
1184
+ arrayOfParams: [code],
1185
+ })];
1186
+ case 3:
1187
+ _a.sent();
1188
+ reject("Command failed with code=".concat(code));
1189
+ return [3 /*break*/, 5];
1190
+ case 4:
1191
+ error_2 = _a.sent();
1192
+ reject(error_2);
1193
+ return [3 /*break*/, 5];
1194
+ case 5: return [3 /*break*/, 7];
1195
+ case 6:
1196
+ reject("Command failed with code=".concat(code));
1197
+ _a.label = 7;
1198
+ case 7: return [3 /*break*/, 9];
1199
+ case 8:
1200
+ resolve(void 0);
1201
+ _a.label = 9;
1202
+ case 9: return [2 /*return*/];
1203
+ }
1204
+ });
1205
+ }); });
1206
+ //#endregion
1207
+ //#region handle stdout error
1208
+ proc.stdout.on('error', function (rawData) {
1209
+ var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1210
+ data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1211
+ outputLineReplace, prefix, extractFromLine);
1212
+ if (!hideOutput.stdout) {
1213
+ process.stdout.write(JSON.stringify(data));
1214
+ }
1215
+ // console.log(data);
1216
+ });
1217
+ //#endregion
1218
+ //#region handle stder data
1219
+ proc.stderr.on('data', function (rawData) {
1220
+ var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1221
+ data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1222
+ outputLineReplace, prefix, extractFromLine);
1223
+ if (!hideOutput.stderr) {
1224
+ process.stderr.write(data);
1225
+ }
1226
+ if (!isResolved && core_imports_1._.isArray(resolvePromiseMsg.stderr)) { // @ts-ignore
1227
+ for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) { // @ts-ignore
1228
+ var rejectm = resolvePromiseMsg.stderr[index];
1229
+ if ((data.search(rejectm) !== -1)) {
1230
+ // Helpers.info(`[unitlOutputContains] Rejected move to next step...`);
1231
+ isResolved = true;
1232
+ reject();
1233
+ proc.kill('SIGINT');
1234
+ break;
1235
+ }
1236
+ }
1237
+ }
1238
+ });
1239
+ //#endregion
1240
+ //#region handle stder error
1241
+ proc.stderr.on('error', function (rawData) {
1242
+ var data = ((rawData === null || rawData === void 0 ? void 0 : rawData.toString()) || '');
1243
+ data = index_1.Helpers.modifyLineByLine(data, // @ts-ignore
1244
+ outputLineReplace, prefix, extractFromLine);
1245
+ // @ts-ignore
1246
+ if (!hideOutput.stderr) {
1247
+ process.stderr.write(JSON.stringify(data));
1248
+ }
1249
+ // console.log(data);
1250
+ });
1251
+ //#endregion
1252
+ });
1253
+ };
1254
+ _b.label = 1;
1255
+ case 1:
1256
+ if (!true) return [3 /*break*/, 9];
1257
+ childProcess = core_imports_1.child_process.exec(command, { cwd: cwd });
1258
+ _b.label = 2;
1259
+ case 2:
1260
+ _b.trys.push([2, 4, , 8]);
1261
+ return [4 /*yield*/, handlProc(childProcess)];
1262
+ case 3:
1263
+ _b.sent();
1264
+ return [3 /*break*/, 9];
1265
+ case 4:
1266
+ error_1 = _b.sent();
1267
+ index_1.Helpers.error("Command failed:\n\n".concat(command, "\n\nin location: ").concat(cwd, "\n\n "), true, true);
1268
+ if (!askToTryAgainOnError) return [3 /*break*/, 6];
1269
+ return [4 /*yield*/, index_1.Helpers.questionYesNo("Try again this command ?")];
1270
+ case 5:
1271
+ if (!(_b.sent())) {
1272
+ throw error_1;
1273
+ }
1274
+ return [3 /*break*/, 7];
1275
+ case 6: throw error_1;
1276
+ case 7: return [3 /*break*/, 8];
1277
+ case 8: return [3 /*break*/, 1];
1278
+ case 9: return [2 /*return*/];
1193
1279
  }
1194
- // console.log(data);
1195
1280
  });
1196
1281
  });
1197
1282
  };
@@ -1292,7 +1377,7 @@ var HelpersCore = /** @class */ (function (_super) {
1292
1377
  if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
1293
1378
  if (notTrim === void 0) { notTrim = false; }
1294
1379
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1295
- var fileContent, error_2;
1380
+ var fileContent, error_3;
1296
1381
  return tslib_1.__generator(this, function (_a) {
1297
1382
  switch (_a.label) {
1298
1383
  case 0:
@@ -1306,7 +1391,7 @@ var HelpersCore = /** @class */ (function (_super) {
1306
1391
  fileContent = index_1.Helpers.readFile(absoluteFilePath, defaultValueWhenNotExists, notTrim);
1307
1392
  return [2 /*return*/, fileContent];
1308
1393
  case 3:
1309
- error_2 = _a.sent();
1394
+ error_3 = _a.sent();
1310
1395
  index_1.Helpers.error("Not able to read locked file: ".concat(absoluteFilePath), true, true);
1311
1396
  return [4 /*yield*/, index_1.Helpers.wait(2)];
1312
1397
  case 4:
@@ -1402,7 +1487,6 @@ var HelpersCore = /** @class */ (function (_super) {
1402
1487
  function currentDate() {
1403
1488
  return "[".concat((0, core_imports_1.dateformat)(new Date(), 'HH:MM:ss'), "]");
1404
1489
  }
1405
- var error_3;
1406
1490
  return tslib_1.__generator(this, function (_a) {
1407
1491
  switch (_a.label) {
1408
1492
  case 0:
@@ -1410,22 +1494,12 @@ var HelpersCore = /** @class */ (function (_super) {
1410
1494
  index_1.Helpers.error("".concat(executionType, " wrapper: \"").concat(fn, "\" is not a function."));
1411
1495
  process.exit(1);
1412
1496
  }
1413
- _a.label = 1;
1414
- case 1:
1415
- _a.trys.push([1, 3, , 4]);
1416
1497
  index_1.Helpers.log("".concat(currentDate(), " ").concat(executionType, " \"").concat(taskName, "\" Started.."));
1417
1498
  return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: fn })];
1418
- case 2:
1499
+ case 1:
1419
1500
  _a.sent();
1420
1501
  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*/];
1502
+ return [2 /*return*/];
1429
1503
  }
1430
1504
  });
1431
1505
  });