@sasjs/cli 3.8.5 → 3.8.8

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.
@@ -478,8 +478,7 @@ function compileWeb(target) {
478
478
  .then(function () { var _a; return (_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Web app services have been compiled."); })
479
479
  .catch(function (err) {
480
480
  var _a;
481
- (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('An error has occurred when compiling web app services.');
482
- throw err;
481
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('An error has occurred when compiling web app services.', err.toString());
483
482
  })];
484
483
  case 2:
485
484
  _c.sent();
@@ -50,7 +50,7 @@ var saveLog_1 = require("../../utils/saveLog");
50
50
  var getLogFilePath_1 = require("../../utils/getLogFilePath");
51
51
  function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath, authConfig, logFile, jobPath, outputPathParam) {
52
52
  return __awaiter(this, void 0, void 0, function () {
53
- var dataJson, configJson, dataFile, configFile, sas9CredentialsError, sasjs, result, isError, sasRequests, currentRequestLog;
53
+ var dataJson, configJson, dataFile, configFile, sas9CredentialsError, sasjs, result;
54
54
  var _this = this;
55
55
  return __generator(this, function (_a) {
56
56
  switch (_a.label) {
@@ -112,7 +112,6 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
112
112
  useComputeApi: false,
113
113
  debug: true
114
114
  });
115
- isError = false;
116
115
  return [4 /*yield*/, sasjs
117
116
  .request(sasJobLocation, dataJson, configJson, function () {
118
117
  (0, displayResult_1.displayError)(null, 'Login callback called. Request failed.');
@@ -122,24 +121,21 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
122
121
  return __generator(this, function (_a) {
123
122
  switch (_a.label) {
124
123
  case 0:
125
- if ((res && res.errorCode) || res.error)
126
- isError = true;
124
+ if (!((res && res.errorCode) || res.error)) return [3 /*break*/, 2];
125
+ (0, displayResult_1.displayError)('Request finished with errors.');
126
+ return [4 /*yield*/, saveLogFile(sasjs, sasJobLocation, logFile, jobPath)];
127
+ case 1:
128
+ _a.sent();
129
+ return [2 /*return*/];
130
+ case 2:
131
+ output = '';
127
132
  if (res === null || res === void 0 ? void 0 : res.result)
128
- res = res.result;
129
- if (typeof res !== 'object') {
130
- try {
131
- output = JSON.stringify(res, null, 2);
132
- }
133
- catch (error) {
134
- (0, displayResult_1.displayError)(error, 'Result parsing failed.');
135
- return [2 /*return*/, error];
136
- }
137
- }
138
- else {
139
- output = res;
140
- }
133
+ output = res.result;
141
134
  return [4 /*yield*/, writeOutput(outputPathParam, output, isLocal)];
142
- case 1:
135
+ case 3:
136
+ _a.sent();
137
+ return [4 /*yield*/, saveLogFile(sasjs, sasJobLocation, logFile, jobPath)];
138
+ case 4:
143
139
  _a.sent();
144
140
  result = true;
145
141
  return [2 /*return*/];
@@ -150,14 +146,13 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
150
146
  return __generator(this, function (_a) {
151
147
  switch (_a.label) {
152
148
  case 0:
153
- isError = true;
154
149
  if (err && err.errorCode === 404) {
155
150
  (0, utils_2.displaySasjsRunnerError)(configJson.username);
156
151
  }
157
152
  else {
158
- (0, displayResult_1.displayError)('', 'An error occurred while executing the request.');
153
+ (0, displayResult_1.displayError)(err, 'An error occurred while executing the request.');
159
154
  }
160
- return [4 /*yield*/, writeOutput(outputPathParam, err, isLocal)];
155
+ return [4 /*yield*/, saveLogFile(sasjs, sasJobLocation, logFile, jobPath)];
161
156
  case 1:
162
157
  _a.sent();
163
158
  result = err;
@@ -167,21 +162,30 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
167
162
  }); })];
168
163
  case 5:
169
164
  _a.sent();
170
- sasRequests = sasjs.getSasRequests();
171
- currentRequestLog = sasRequests.find(function (x) { return x.serviceLink === sasJobLocation; });
172
- if (!(currentRequestLog && ((logFile && jobPath) || isError))) return [3 /*break*/, 7];
173
- if (!logFile)
174
- logFile = (0, getLogFilePath_1.getLogFilePath)('', jobPath || '');
175
- return [4 /*yield*/, (0, saveLog_1.saveLog)(currentRequestLog.logFile, logFile, jobPath || '', false)];
176
- case 6:
177
- _a.sent();
178
- _a.label = 7;
179
- case 7: return [2 /*return*/, result];
165
+ return [2 /*return*/, result];
180
166
  }
181
167
  });
182
168
  });
183
169
  }
184
170
  exports.runSasJob = runSasJob;
171
+ var saveLogFile = function (sasjs, sasJobLocation, logFile, jobPath) { return __awaiter(void 0, void 0, void 0, function () {
172
+ var sasRequests, currentRequestLog;
173
+ return __generator(this, function (_a) {
174
+ switch (_a.label) {
175
+ case 0:
176
+ sasRequests = sasjs.getSasRequests();
177
+ currentRequestLog = sasRequests.find(function (x) { return x.serviceLink === sasJobLocation; });
178
+ if (!(currentRequestLog && jobPath)) return [3 /*break*/, 2];
179
+ if (!logFile)
180
+ logFile = (0, getLogFilePath_1.getLogFilePath)('', jobPath || '');
181
+ return [4 /*yield*/, (0, saveLog_1.saveLog)(currentRequestLog.logFile, logFile, jobPath || '', false)];
182
+ case 1:
183
+ _a.sent();
184
+ _a.label = 2;
185
+ case 2: return [2 /*return*/];
186
+ }
187
+ });
188
+ }); };
185
189
  /**
186
190
  * Writes output to the file
187
191
  * @param outputPathParam path to output file
@@ -217,7 +221,13 @@ var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter
217
221
  }
218
222
  outputString = '';
219
223
  if (typeof output === 'object') {
220
- outputString = JSON.stringify(output);
224
+ try {
225
+ outputString = JSON.stringify(output, null, 2);
226
+ }
227
+ catch (error) {
228
+ (0, displayResult_1.displayError)(error, 'Result parsing failed.');
229
+ return [2 /*return*/];
230
+ }
221
231
  }
222
232
  else {
223
233
  outputString = output;
package/package.json CHANGED
@@ -47,7 +47,7 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@sasjs/adapter": "3.7.12",
50
+ "@sasjs/adapter": "^3.7.14",
51
51
  "@sasjs/core": "4.15.3",
52
52
  "@sasjs/lint": "1.11.2",
53
53
  "@sasjs/utils": "2.36.0",
@@ -94,5 +94,5 @@
94
94
  "typescript": "4.5.4",
95
95
  "util": "0.12.4"
96
96
  },
97
- "version": "3.8.5"
97
+ "version": "3.8.8"
98
98
  }