@sasjs/cli 6.2.3 → 6.2.5

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.
package/README.md CHANGED
@@ -16,6 +16,7 @@
16
16
 
17
17
  - Scaffold a new SAS App in seconds (`sasjs create myApp -t jobs`)
18
18
  - Compile / Build SAS Jobs, Services & Macros _locally_ and deploy / execute _remotely_, in isolation from other developers (`sasjs cbd`)
19
+ - Compile a single Job, Service or Test without touching the rest of the build (`sasjs compile identify --source sasjs/jobs/daily/load.sas`)
19
20
  - No dependency on the server filesystem
20
21
  - Optionally synchronise a local folder onto the server filesystem using `sasjs fs`
21
22
  - Trigger Viya Jobs & Flows (`sasjs job execute` / `sasjs flow execute`)
@@ -435,13 +435,13 @@ function getContentFor(rootDirectory, folderPath, serverType) {
435
435
  _a = utils_1.removeHeader;
436
436
  return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
437
437
  case 1:
438
- fileContent = _a.apply(void 0, [_b.sent()]);
438
+ fileContent = _a.apply(void 0, [_b.sent(), filePath]);
439
439
  transformedContent = getServiceText(file, fileContent, serverType);
440
440
  content += "\n".concat(transformedContent, "\n");
441
441
  contentJSON.members.push({
442
442
  name: file.replace(/.sas$/, ''),
443
443
  type: types_1.MemberType.service,
444
- code: (0, utils_1.removeHeader)(fileContent)
444
+ code: (0, utils_1.removeHeader)(fileContent, filePath)
445
445
  });
446
446
  return [3 /*break*/, 4];
447
447
  case 2: return [4 /*yield*/, (0, utils_1.base64EncodeFile)(filePath)];
@@ -3,7 +3,13 @@ import { TargetCommand } from '../../types/command/targetCommand';
3
3
  export declare class CompileCommand extends TargetCommand {
4
4
  constructor(args: string[]);
5
5
  get source(): string;
6
- get output(): string;
6
+ /**
7
+ * The base folder requested with `--output`, or undefined to let the compile
8
+ * use the build folder for the file's type. The type sub folder, the
9
+ * configured folder's name and the file's own path below it are added by
10
+ * compileSingleFile, so there is one implementation of the destination.
11
+ */
12
+ getOutputPath(): string | undefined;
7
13
  execute(): Promise<ReturnCode>;
8
14
  executeCompile(): Promise<ReturnCode>;
9
15
  executeSingleFileCompile(): Promise<ReturnCode>;
@@ -50,17 +50,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
50
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
51
  }
52
52
  };
53
- var __importDefault = (this && this.__importDefault) || function (mod) {
54
- return (mod && mod.__esModule) ? mod : { "default": mod };
55
- };
56
53
  Object.defineProperty(exports, "__esModule", { value: true });
57
54
  exports.CompileCommand = void 0;
58
55
  var command_1 = require("../../types/command");
59
56
  var targetCommand_1 = require("../../types/command/targetCommand");
60
57
  var utils_1 = require("../../utils");
61
58
  var compile_1 = require("./compile");
62
- var path_1 = __importDefault(require("path"));
63
- var getDestinationPath_1 = require("./internal/getDestinationPath");
64
59
  var compileSingleFile_1 = require("./compileSingleFile");
65
60
  var utils_2 = require("@sasjs/utils");
66
61
  var CompileSubCommand;
@@ -73,15 +68,23 @@ var CompileSubCommand;
73
68
  var syntax = 'compile [subCommand]';
74
69
  var aliases = ['c'];
75
70
  var usage = 'Usage: sasjs compile [subCommand] [options]';
76
- var description = 'Compiles jobs and services in the project by inlining all dependencies and adds init and term programs as configured in the specified target.';
71
+ var description = 'Compiles jobs and services in the project by inlining all dependencies and adds init and term programs as configured in the specified target. With a subCommand (job, service, test or identify) and --source, compiles a single file to the folder matching its type.';
77
72
  var examples = [
78
73
  {
79
74
  command: 'sasjs compile -t myTarget',
80
- description: ''
75
+ description: 'compiles every job and service in the project'
81
76
  },
82
77
  {
83
78
  command: 'sasjs c -t myTarget',
84
- description: ''
79
+ description: 'the same, using the alias'
80
+ },
81
+ {
82
+ command: 'sasjs compile job --source sasjs/jobs/daily/load.sas -t myTarget',
83
+ description: 'compiles one job'
84
+ },
85
+ {
86
+ command: 'sasjs compile identify --source sasjs/services/admin/users.sas -t myTarget -o /tmp/out',
87
+ description: 'works out the file type and compiles it below /tmp/out'
85
88
  }
86
89
  ];
87
90
  var subCommandParseOptions = {
@@ -110,31 +113,16 @@ var CompileCommand = /** @class */ (function (_super) {
110
113
  enumerable: false,
111
114
  configurable: true
112
115
  });
113
- Object.defineProperty(CompileCommand.prototype, "output", {
114
- get: function () {
115
- var value = this.parsed.output;
116
- var sourcefilePathParts = path_1.default.normalize(this.source).split(path_1.default.sep);
117
- sourcefilePathParts.splice(-1, 1);
118
- var sourceFolderPath = sourcefilePathParts.join(path_1.default.sep);
119
- var leafFolderName = sourceFolderPath.split(path_1.default.sep).pop();
120
- var outputPath;
121
- if (value) {
122
- var internal = [value, "".concat(this.subCommand, "s")];
123
- if (leafFolderName)
124
- internal.push(leafFolderName);
125
- outputPath = (0, utils_2.getAbsolutePath)(internal.join(path_1.default.sep), process.currentDir);
126
- }
127
- else {
128
- outputPath =
129
- this.subCommand === 'job'
130
- ? (0, getDestinationPath_1.getDestinationJobPath)(sourceFolderPath)
131
- : (0, getDestinationPath_1.getDestinationServicePath)(sourceFolderPath);
132
- }
133
- return outputPath;
134
- },
135
- enumerable: false,
136
- configurable: true
137
- });
116
+ /**
117
+ * The base folder requested with `--output`, or undefined to let the compile
118
+ * use the build folder for the file's type. The type sub folder, the
119
+ * configured folder's name and the file's own path below it are added by
120
+ * compileSingleFile, so there is one implementation of the destination.
121
+ */
122
+ CompileCommand.prototype.getOutputPath = function () {
123
+ var value = this.parsed.output;
124
+ return value ? (0, utils_2.getAbsolutePath)(value, process.currentDir) : undefined;
125
+ };
138
126
  CompileCommand.prototype.execute = function () {
139
127
  return __awaiter(this, void 0, void 0, function () {
140
128
  var _a;
@@ -181,16 +169,16 @@ var CompileCommand = /** @class */ (function (_super) {
181
169
  };
182
170
  CompileCommand.prototype.executeSingleFileCompile = function () {
183
171
  return __awaiter(this, void 0, void 0, function () {
184
- var target, output;
172
+ var target;
185
173
  return __generator(this, function (_a) {
186
174
  switch (_a.label) {
187
- case 0: return [4 /*yield*/, this.getTargetInfo()];
175
+ case 0: return [4 /*yield*/, this.getTargetInfo()
176
+ // 'identify' is resolved once, in compileSingleFile, so the command and
177
+ // other callers such as `sasjs run --compile` cannot disagree about it.
178
+ ];
188
179
  case 1:
189
180
  target = (_a.sent()).target;
190
- return [4 /*yield*/, this.output];
191
- case 2:
192
- output = _a.sent();
193
- return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)(target, this.parsed.subCommand, this.source, output)
181
+ return [4 /*yield*/, (0, compileSingleFile_1.compileSingleFile)(target, this.parsed.subCommand, this.source, this.getOutputPath())
194
182
  .then(function (res) {
195
183
  var _a;
196
184
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("Source has been successfully compiled!\nThe compiled output is located at: ".concat(res.destinationPath));
@@ -200,7 +188,10 @@ var CompileCommand = /** @class */ (function (_super) {
200
188
  (0, utils_1.displayError)(err, 'Error compiling source.');
201
189
  return command_1.ReturnCode.InternalError;
202
190
  })];
203
- case 3: return [2 /*return*/, _a.sent()];
191
+ case 2:
192
+ // 'identify' is resolved once, in compileSingleFile, so the command and
193
+ // other callers such as `sasjs run --compile` cannot disagree about it.
194
+ return [2 /*return*/, _a.sent()];
204
195
  }
205
196
  });
206
197
  });
@@ -4,6 +4,6 @@ export declare enum CompileSingleFileSubCommands {
4
4
  Service = "service",
5
5
  Test = "test"
6
6
  }
7
- export declare function compileSingleFile(target: Target, subCommand: string | undefined, source: string, output: string, insertProgramVar?: boolean, currentFolder?: string): Promise<{
7
+ export declare function compileSingleFile(target: Target, subCommand: string | undefined, source: string, output?: string, insertProgramVar?: boolean, currentFolder?: string): Promise<{
8
8
  destinationPath: string;
9
9
  }>;
@@ -35,6 +35,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
62
+ };
38
63
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
64
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
65
  };
@@ -55,14 +80,117 @@ var CompileSingleFileSubCommands;
55
80
  var isCompileSingleFileSubCommands = function (command) {
56
81
  return Object.values(CompileSingleFileSubCommands).includes(command);
57
82
  };
83
+ /** The longest configured folder that contains the given folder, if any. */
84
+ var getContainingFolder = function (folders, folder) {
85
+ return folders
86
+ .filter(function (configured) {
87
+ return folder === configured || folder.startsWith(configured + path_1.default.sep);
88
+ })
89
+ .sort(function (a, b) { return b.length - a.length; })[0];
90
+ };
91
+ /** The configured folders that can hold a file of this type. */
92
+ var getConfiguredFolders = function (target, subCommand) { return __awaiter(void 0, void 0, void 0, function () {
93
+ var _a, _b, _c;
94
+ return __generator(this, function (_d) {
95
+ switch (_d.label) {
96
+ case 0:
97
+ if (!(subCommand === CompileSingleFileSubCommands.Service)) return [3 /*break*/, 2];
98
+ return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Service)];
99
+ case 1: return [2 /*return*/, _d.sent()];
100
+ case 2:
101
+ if (!(subCommand === CompileSingleFileSubCommands.Job)) return [3 /*break*/, 4];
102
+ return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Job)];
103
+ case 3: return [2 /*return*/, _d.sent()];
104
+ case 4:
105
+ _a = [[]];
106
+ return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Service)];
107
+ case 5:
108
+ _b = [__spreadArray.apply(void 0, _a.concat([__read.apply(void 0, [(_d.sent())]), false]))];
109
+ return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Job)];
110
+ case 6:
111
+ _c = [__spreadArray.apply(void 0, _b.concat([__read.apply(void 0, [(_d.sent())]), false]))];
112
+ return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
113
+ case 7: return [2 /*return*/, __spreadArray.apply(void 0, _c.concat([__read.apply(void 0, [(_d.sent())]), false]))];
114
+ }
115
+ });
116
+ }); };
117
+ /** A test is filed under tests/services, tests/jobs or tests/macros. */
118
+ var getTestType = function (target, sourceFolder) { return __awaiter(void 0, void 0, void 0, function () {
119
+ var segments, testsIndex, fromPath, byType, _a, fromConfiguredFolders;
120
+ var _b, _c, _d;
121
+ var _e;
122
+ return __generator(this, function (_f) {
123
+ switch (_f.label) {
124
+ case 0:
125
+ segments = sourceFolder.split(path_1.default.sep);
126
+ testsIndex = segments.lastIndexOf('tests');
127
+ if (testsIndex !== -1) {
128
+ fromPath = segments[testsIndex + 1];
129
+ if (['services', 'jobs', 'macros'].includes(fromPath))
130
+ return [2 /*return*/, fromPath];
131
+ }
132
+ _b = {
133
+ type: 'services'
134
+ };
135
+ return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Service)];
136
+ case 1:
137
+ _a = [
138
+ (_b.folders = _f.sent(),
139
+ _b)
140
+ ];
141
+ _c = { type: 'jobs' };
142
+ return [4 /*yield*/, (0, internal_1.getAllFolders)(target, internal_1.SasFileType.Job)];
143
+ case 2:
144
+ _a = _a.concat([
145
+ (_c.folders = _f.sent(), _c)
146
+ ]);
147
+ _d = { type: 'macros' };
148
+ return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
149
+ case 3:
150
+ byType = _a.concat([
151
+ (_d.folders = _f.sent(), _d)
152
+ ]);
153
+ fromConfiguredFolders = (_e = byType.find(function (_a) {
154
+ var folders = _a.folders;
155
+ return getContainingFolder(folders, sourceFolder);
156
+ })) === null || _e === void 0 ? void 0 : _e.type;
157
+ if (!fromConfiguredFolders) {
158
+ throw new Error("Single file compilation failed. Cannot tell which test tree ".concat(sourceFolder, " belongs to - keep the test under a configured folder, or under tests/services, tests/jobs or tests/macros."));
159
+ }
160
+ return [2 /*return*/, fromConfiguredFolders];
161
+ }
162
+ });
163
+ }); };
164
+ /** The folder a file of this type is written under. */
165
+ var getTypeFolderName = function (subCommand, testType) {
166
+ switch (subCommand) {
167
+ case CompileSingleFileSubCommands.Job:
168
+ return 'jobs';
169
+ case CompileSingleFileSubCommands.Service:
170
+ return 'services';
171
+ case CompileSingleFileSubCommands.Test:
172
+ return path_1.default.posix.join('tests', testType);
173
+ default:
174
+ throw new Error("Single file compilation failed. Unsupported sub command: ".concat(subCommand));
175
+ }
176
+ };
177
+ /** The build folder a project compile uses for this type. */
178
+ var getBaseFolder = function (subCommand, testType) {
179
+ var _a = process.sasjsConstants, buildDestinationJobsFolder = _a.buildDestinationJobsFolder, buildDestinationServicesFolder = _a.buildDestinationServicesFolder, buildDestinationTestFolder = _a.buildDestinationTestFolder;
180
+ if (subCommand === CompileSingleFileSubCommands.Job)
181
+ return buildDestinationJobsFolder;
182
+ if (subCommand === CompileSingleFileSubCommands.Service)
183
+ return buildDestinationServicesFolder;
184
+ return path_1.default.join(buildDestinationTestFolder, testType);
185
+ };
58
186
  function compileSingleFile(target_1) {
59
187
  return __awaiter(this, arguments, void 0, function (target, subCommand, source, output, insertProgramVar, currentFolder) {
60
- var commandExample, sourcePath, outputPathParts, leafFolderName, parentOutputFolder, pathExists, sourceFileName, destinationPath, sourceFileNameWithoutExt, macroFolders, programFolders, psMaxOption, programVar, compileTree, sourceFolder, _a;
61
- var _b;
188
+ var commandExample, sourcePath, sourcePathParts, sourceFileName, sourceFileNameWithoutExt, sourceFolder, configuredFolders, configuredFolder, leafFolderName, relativeFolder, testType, _a, typeFolderName, destinationFolder, destinationPath, macroFolders, programFolders, psMaxOption, programFolder, programVar, compileTree, _b;
189
+ var _c;
62
190
  if (subCommand === void 0) { subCommand = 'identify'; }
63
191
  if (insertProgramVar === void 0) { insertProgramVar = false; }
64
- return __generator(this, function (_c) {
65
- switch (_c.label) {
192
+ return __generator(this, function (_d) {
193
+ switch (_d.label) {
66
194
  case 0:
67
195
  if (!isCompileSingleFileSubCommands(subCommand) &&
68
196
  subCommand !== 'identify') {
@@ -76,7 +204,7 @@ function compileSingleFile(target_1) {
76
204
  sourcePath = (0, utils_1.getAbsolutePath)(source, currentFolder || process.currentDir);
77
205
  return [4 /*yield*/, validateSourcePath(sourcePath)];
78
206
  case 1:
79
- if (!(_c.sent())) {
207
+ if (!(_d.sent())) {
80
208
  throw new Error("Provide a valid path to source file (eg '".concat(commandExample, "')"));
81
209
  }
82
210
  if (!(subCommand === 'identify')) return [3 /*break*/, 3];
@@ -84,68 +212,89 @@ function compileSingleFile(target_1) {
84
212
  throw (0, error_1.prefixMessage)(err, 'Single file compilation failed. ');
85
213
  })];
86
214
  case 2:
87
- subCommand = _c.sent();
88
- _c.label = 3;
215
+ subCommand = _d.sent();
216
+ _d.label = 3;
89
217
  case 3:
90
- (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Compiling source file:\n- ".concat(sourcePath));
91
- outputPathParts = output.split(path_1.default.sep);
92
- (outputPathParts.pop(), outputPathParts.pop());
93
- leafFolderName = source.split(path_1.default.sep).pop();
94
- parentOutputFolder = outputPathParts.join(path_1.default.sep);
95
- return [4 /*yield*/, (0, utils_1.fileExists)(parentOutputFolder)];
218
+ (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Compiling source file:\n- ".concat(sourcePath));
219
+ sourcePathParts = sourcePath.split(path_1.default.sep);
220
+ sourceFileName = sourcePathParts.pop();
221
+ sourceFileNameWithoutExt = sourceFileName.replace(/\.sas$/i, '');
222
+ sourceFolder = sourcePathParts.join(path_1.default.sep);
223
+ return [4 /*yield*/, getConfiguredFolders(target, subCommand)];
96
224
  case 4:
97
- pathExists = _c.sent();
98
- if (!pathExists) return [3 /*break*/, 6];
99
- return [4 /*yield*/, (0, utils_1.deleteFolder)(parentOutputFolder)];
225
+ configuredFolders = _d.sent();
226
+ configuredFolder = getContainingFolder(configuredFolders, sourceFolder);
227
+ leafFolderName = configuredFolder
228
+ ? path_1.default.basename(configuredFolder)
229
+ : configuredFolders.length
230
+ ? ''
231
+ : path_1.default.basename(sourceFolder);
232
+ relativeFolder = configuredFolder
233
+ ? path_1.default.relative(configuredFolder, sourceFolder)
234
+ : '';
235
+ if (!(subCommand === CompileSingleFileSubCommands.Test)) return [3 /*break*/, 6];
236
+ return [4 /*yield*/, getTestType(target, sourceFolder)];
100
237
  case 5:
101
- _c.sent();
102
- _c.label = 6;
103
- case 6: return [4 /*yield*/, (0, utils_1.createFolder)(output)];
238
+ _a = _d.sent();
239
+ return [3 /*break*/, 7];
240
+ case 6:
241
+ _a = undefined;
242
+ _d.label = 7;
104
243
  case 7:
105
- _c.sent();
106
- sourceFileName = sourcePath.split(path_1.default.sep).pop();
107
- destinationPath = path_1.default.join(output, sourceFileName);
108
- return [4 /*yield*/, (0, utils_1.copy)(sourcePath, destinationPath)];
244
+ testType = _a;
245
+ typeFolderName = getTypeFolderName(subCommand, testType);
246
+ destinationFolder = output
247
+ ? path_1.default.join(output, typeFolderName, leafFolderName, relativeFolder)
248
+ : path_1.default.join(getBaseFolder(subCommand, testType), leafFolderName, relativeFolder);
249
+ // Nothing is deleted: the folder is created if missing and the compiled file
250
+ // overwrites its previous copy, so siblings in the same leaf folder survive.
251
+ return [4 /*yield*/, (0, utils_1.createFolder)(destinationFolder)];
109
252
  case 8:
110
- _c.sent();
111
- sourceFileNameWithoutExt = sourceFileName.split('.')[0];
112
- return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
253
+ // Nothing is deleted: the folder is created if missing and the compiled file
254
+ // overwrites its previous copy, so siblings in the same leaf folder survive.
255
+ _d.sent();
256
+ destinationPath = path_1.default.join(destinationFolder, sourceFileName);
257
+ return [4 /*yield*/, (0, utils_1.copy)(sourcePath, destinationPath)];
113
258
  case 9:
114
- macroFolders = _c.sent();
115
- return [4 /*yield*/, (0, config_1.getProgramFolders)(target)];
259
+ _d.sent();
260
+ return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
116
261
  case 10:
117
- programFolders = _c.sent();
262
+ macroFolders = _d.sent();
263
+ return [4 /*yield*/, (0, config_1.getProgramFolders)(target)];
264
+ case 11:
265
+ programFolders = _d.sent();
118
266
  psMaxOption = 'options ps=max;';
267
+ programFolder = [typeFolderName, leafFolderName, relativeFolder]
268
+ .filter(Boolean)
269
+ .join('/')
270
+ .split(path_1.default.sep)
271
+ .join('/');
119
272
  programVar = insertProgramVar
120
- ? "%let _program=".concat(target.appLoc, "/").concat(subCommand, "s/").concat(leafFolderName, "/").concat(sourceFileNameWithoutExt, ";\n").concat(psMaxOption)
273
+ ? "%let _program=".concat(target.appLoc, "/").concat(programFolder, "/").concat(sourceFileNameWithoutExt, ";\n").concat(psMaxOption)
121
274
  : "".concat(psMaxOption);
122
275
  compileTree = (0, internal_1.getCompileTree)(target);
123
- sourceFolder = sourcePath
124
- .split(path_1.default.sep)
125
- .slice(0, sourcePath.split(path_1.default.sep).length - 1)
126
- .join(path_1.default.sep);
127
- _a = subCommand;
128
- switch (_a) {
129
- case CompileSingleFileSubCommands.Service: return [3 /*break*/, 11];
130
- case CompileSingleFileSubCommands.Job: return [3 /*break*/, 13];
131
- case CompileSingleFileSubCommands.Test: return [3 /*break*/, 15];
276
+ _b = subCommand;
277
+ switch (_b) {
278
+ case CompileSingleFileSubCommands.Service: return [3 /*break*/, 12];
279
+ case CompileSingleFileSubCommands.Job: return [3 /*break*/, 14];
280
+ case CompileSingleFileSubCommands.Test: return [3 /*break*/, 16];
132
281
  }
133
- return [3 /*break*/, 17];
134
- case 11: return [4 /*yield*/, (0, internal_1.compileFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree, utils_1.SASJsFileType.service, sourceFolder)];
135
- case 12:
136
- _c.sent();
137
- return [3 /*break*/, 17];
138
- case 13: return [4 /*yield*/, (0, internal_1.compileFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree, utils_1.SASJsFileType.job, sourceFolder)];
139
- case 14:
140
- _c.sent();
141
- return [3 /*break*/, 17];
142
- case 15: return [4 /*yield*/, (0, internal_1.compileTestFile)(target, sourcePath, programVar, undefined, false, compileTree, destinationPath)];
143
- case 16:
144
- _c.sent();
145
- return [3 /*break*/, 17];
146
- case 17: return [4 /*yield*/, compileTree.saveTree()];
147
- case 18:
148
- _c.sent();
282
+ return [3 /*break*/, 18];
283
+ case 12: return [4 /*yield*/, (0, internal_1.compileFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree, utils_1.SASJsFileType.service, sourceFolder)];
284
+ case 13:
285
+ _d.sent();
286
+ return [3 /*break*/, 18];
287
+ case 14: return [4 /*yield*/, (0, internal_1.compileFile)(target, destinationPath, macroFolders, programFolders, programVar, compileTree, utils_1.SASJsFileType.job, sourceFolder)];
288
+ case 15:
289
+ _d.sent();
290
+ return [3 /*break*/, 18];
291
+ case 16: return [4 /*yield*/, (0, internal_1.compileTestFile)(target, sourcePath, programVar, undefined, false, compileTree, destinationPath)];
292
+ case 17:
293
+ _d.sent();
294
+ return [3 /*break*/, 18];
295
+ case 18: return [4 /*yield*/, compileTree.saveTree()];
296
+ case 19:
297
+ _d.sent();
149
298
  return [2 /*return*/, { destinationPath: destinationPath }];
150
299
  }
151
300
  });
@@ -77,23 +77,25 @@ var getAllFolders = function (target, type, rootConfig) { return __awaiter(void
77
77
  allFolders = __spreadArray(__spreadArray([], __read((allFolders || [])), false), __read((folders || [])), false);
78
78
  };
79
79
  if (type === SasFileType.Service) {
80
- config = configuration.serviceConfig;
80
+ config = configuration === null || configuration === void 0 ? void 0 : configuration.serviceConfig;
81
81
  folders = config === null || config === void 0 ? void 0 : config.serviceFolders;
82
82
  addFolders(folders);
83
- config = target.serviceConfig;
83
+ config = target === null || target === void 0 ? void 0 : target.serviceConfig;
84
84
  folders = config === null || config === void 0 ? void 0 : config.serviceFolders;
85
85
  }
86
86
  else {
87
- config = configuration.jobConfig;
87
+ config = configuration === null || configuration === void 0 ? void 0 : configuration.jobConfig;
88
88
  folders = config === null || config === void 0 ? void 0 : config.jobFolders;
89
89
  addFolders(folders);
90
- config = target.jobConfig;
90
+ config = target === null || target === void 0 ? void 0 : target.jobConfig;
91
91
  folders = config === null || config === void 0 ? void 0 : config.jobFolders;
92
92
  }
93
93
  addFolders(folders);
94
94
  if (!allFolders)
95
95
  return [2 /*return*/, []];
96
96
  allFolders = allFolders.filter(function (p) { return !!p; });
97
+ if (!allFolders.length)
98
+ return [2 /*return*/, []];
97
99
  buildSourceFolder = process.sasjsConstants.buildSourceFolder;
98
100
  allFolders = allFolders.map(function (sasFile) {
99
101
  return (0, utils_1.getAbsolutePath)(sasFile, buildSourceFolder);
@@ -59,7 +59,7 @@ function loadDependencies(target, filePath, macroFolders, programFolders, type,
59
59
  return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
60
60
  case 1:
61
61
  // If file is of a generic type SASJsFileType.file, then just read the file content without header
62
- fileContent = _a.apply(void 0, [_d.sent()]);
62
+ fileContent = _a.apply(void 0, [_d.sent(), filePath]);
63
63
  return [3 /*break*/, 5];
64
64
  case 2:
65
65
  leaf = compileTree.getLeaf(filePath);