@sasjs/cli 4.0.1 → 4.0.2

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.
@@ -1,6 +1,5 @@
1
1
  import { TestFlow } from '../../../types';
2
2
  import { Target, Configuration, CompileTree } from '@sasjs/utils';
3
3
  export declare function compileTestFile(target: Target, filePath: string, testVar: string | undefined, saveToRoot: boolean | undefined, removeOriginalFile: boolean | undefined, compileTree: CompileTree): Promise<void>;
4
- export declare function moveTestFile(filePath: string): Promise<void>;
5
4
  export declare function copyTestMacroFiles(folderAbsolutePath: string): Promise<void>;
6
5
  export declare const compileTestFlow: (target: Target, config?: Configuration) => Promise<TestFlow | undefined>;
@@ -64,7 +64,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
64
64
  return (mod && mod.__esModule) ? mod : { "default": mod };
65
65
  };
66
66
  Object.defineProperty(exports, "__esModule", { value: true });
67
- exports.compileTestFlow = exports.copyTestMacroFiles = exports.moveTestFile = exports.compileTestFile = void 0;
67
+ exports.compileTestFlow = exports.copyTestMacroFiles = exports.compileTestFile = void 0;
68
68
  var types_1 = require("../../../types");
69
69
  var path_1 = __importDefault(require("path"));
70
70
  var utils_1 = require("@sasjs/utils");
@@ -72,99 +72,59 @@ var loadDependencies_1 = require("./loadDependencies");
72
72
  var file_1 = require("../../../utils/file");
73
73
  var chalk_1 = __importDefault(require("chalk"));
74
74
  var config_1 = require("../../../utils/config");
75
- var testsBuildFolder = function () {
76
- return path_1.default.join(process.projectDir, 'sasjsbuild', 'tests');
77
- };
78
75
  var getFileName = function (filePath) { return path_1.default.parse(filePath).base; };
79
76
  function compileTestFile(target, filePath, testVar, saveToRoot, removeOriginalFile, compileTree) {
80
77
  if (testVar === void 0) { testVar = ''; }
81
78
  if (saveToRoot === void 0) { saveToRoot = true; }
82
79
  if (removeOriginalFile === void 0) { removeOriginalFile = true; }
83
80
  return __awaiter(this, void 0, void 0, function () {
84
- var dependencies, _a, _b, destinationPath;
85
- return __generator(this, function (_c) {
86
- switch (_c.label) {
81
+ var dependencies, _a, _b, _c, buildDestinationFolder, buildDestinationTestFolder, buildDestinationFolderName, destinationPath;
82
+ return __generator(this, function (_d) {
83
+ switch (_d.label) {
87
84
  case 0:
88
85
  _a = loadDependencies_1.loadDependencies;
89
86
  _b = [target,
90
87
  (0, utils_1.getAbsolutePath)(filePath, process.projectDir)];
91
88
  return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
92
89
  case 1:
93
- _b = _b.concat([_c.sent()]);
90
+ _b = _b.concat([_d.sent()]);
94
91
  return [4 /*yield*/, (0, config_1.getProgramFolders)(target)];
95
- case 2: return [4 /*yield*/, _a.apply(void 0, _b.concat([_c.sent(), utils_1.SASJsFileType.test,
92
+ case 2: return [4 /*yield*/, _a.apply(void 0, _b.concat([_d.sent(), utils_1.SASJsFileType.test,
96
93
  compileTree]))];
97
94
  case 3:
98
- dependencies = _c.sent();
95
+ dependencies = _d.sent();
99
96
  dependencies = "".concat(testVar ? testVar + '\n' : '', "\n").concat(dependencies);
100
- destinationPath = path_1.default.join(testsBuildFolder(), saveToRoot
97
+ _c = process.sasjsConstants, buildDestinationFolder = _c.buildDestinationFolder, buildDestinationTestFolder = _c.buildDestinationTestFolder;
98
+ buildDestinationFolderName = buildDestinationFolder
99
+ .split(path_1.default.sep)
100
+ .pop();
101
+ destinationPath = path_1.default.join(buildDestinationTestFolder, saveToRoot
101
102
  ? filePath.split(path_1.default.sep).pop() || ''
102
103
  : filePath
103
104
  .split(path_1.default.sep)
104
105
  .reduce(function (acc, item, i, arr) {
105
106
  return acc.length
106
- ? __spreadArray(__spreadArray([], __read(acc), false), [item], false) : arr[i - 1] === 'sasjsbuild'
107
+ ? __spreadArray(__spreadArray([], __read(acc), false), [item], false) : arr[i - 1] === buildDestinationFolderName
107
108
  ? __spreadArray(__spreadArray([], __read(acc), false), [item], false) : acc;
108
109
  }, [])
109
110
  .join(path_1.default.sep));
110
111
  return [4 /*yield*/, (0, utils_1.createFile)(destinationPath, dependencies)];
111
112
  case 4:
112
- _c.sent();
113
+ _d.sent();
113
114
  if (!removeOriginalFile) return [3 /*break*/, 6];
114
115
  return [4 /*yield*/, (0, utils_1.deleteFile)(filePath)];
115
116
  case 5:
116
- _c.sent();
117
- _c.label = 6;
117
+ _d.sent();
118
+ _d.label = 6;
118
119
  case 6: return [2 /*return*/];
119
120
  }
120
121
  });
121
122
  });
122
123
  }
123
124
  exports.compileTestFile = compileTestFile;
124
- function moveTestFile(filePath) {
125
- return __awaiter(this, void 0, void 0, function () {
126
- var fileName, destinationPath, testDestinationFolder, sourceFolder;
127
- return __generator(this, function (_a) {
128
- switch (_a.label) {
129
- case 0:
130
- fileName = filePath.split(path_1.default.sep).pop();
131
- if (!(0, utils_1.isTestFile)(fileName))
132
- return [2 /*return*/];
133
- destinationPath = filePath.replace('sasjsbuild', 'sasjsbuild/tests');
134
- testDestinationFolder = destinationPath
135
- .split(path_1.default.sep)
136
- .slice(0, -1)
137
- .join(path_1.default.sep);
138
- return [4 /*yield*/, (0, utils_1.folderExists)(testDestinationFolder)];
139
- case 1:
140
- if (!!(_a.sent())) return [3 /*break*/, 3];
141
- return [4 /*yield*/, (0, utils_1.createFolder)(testDestinationFolder)];
142
- case 2:
143
- _a.sent();
144
- _a.label = 3;
145
- case 3: return [4 /*yield*/, (0, utils_1.moveFile)(filePath, destinationPath)];
146
- case 4:
147
- _a.sent();
148
- sourceFolder = filePath
149
- .split(path_1.default.sep)
150
- .slice(0, filePath.split(path_1.default.sep).length - 1)
151
- .join(path_1.default.sep);
152
- return [4 /*yield*/, (0, utils_1.listFilesInFolder)(sourceFolder)];
153
- case 5:
154
- if (!((_a.sent()).length === 0)) return [3 /*break*/, 7];
155
- return [4 /*yield*/, (0, utils_1.deleteFolder)(sourceFolder)];
156
- case 6:
157
- _a.sent();
158
- _a.label = 7;
159
- case 7: return [2 /*return*/];
160
- }
161
- });
162
- });
163
- }
164
- exports.moveTestFile = moveTestFile;
165
125
  function copyTestMacroFiles(folderAbsolutePath) {
166
126
  return __awaiter(this, void 0, void 0, function () {
167
- var macroFiles, macroTestFiles;
127
+ var macroFiles, macroTestFiles, buildDestinationTestFolder;
168
128
  var _this = this;
169
129
  return __generator(this, function (_a) {
170
130
  switch (_a.label) {
@@ -172,12 +132,13 @@ function copyTestMacroFiles(folderAbsolutePath) {
172
132
  case 1:
173
133
  macroFiles = _a.sent();
174
134
  macroTestFiles = macroFiles.filter(function (item) { return utils_1.testFileRegExp.test(item); });
135
+ buildDestinationTestFolder = process.sasjsConstants.buildDestinationTestFolder;
175
136
  return [4 /*yield*/, (0, utils_1.asyncForEach)(macroTestFiles, function (file) { return __awaiter(_this, void 0, void 0, function () {
176
137
  var destinationFile;
177
138
  return __generator(this, function (_a) {
178
139
  switch (_a.label) {
179
140
  case 0:
180
- destinationFile = path_1.default.join(testsBuildFolder(), 'macros', file);
141
+ destinationFile = path_1.default.join(buildDestinationTestFolder, 'macros', file);
181
142
  return [4 /*yield*/, (0, utils_1.fileExists)(destinationFile)];
182
143
  case 1:
183
144
  if (!!(_a.sent())) return [3 /*break*/, 3];
@@ -160,64 +160,6 @@ describe('compileTestFile', function () {
160
160
  });
161
161
  }); });
162
162
  });
163
- describe('moveTestFile', function () {
164
- it('should move service test', function () { return __awaiter(void 0, void 0, void 0, function () {
165
- var relativePath, buildPath, originalFilePath, destinationFilePath;
166
- return __generator(this, function (_a) {
167
- switch (_a.label) {
168
- case 0:
169
- relativePath = path_1.default.join('services', 'services', 'admin', testFileName);
170
- buildPath = path_1.default.join(__dirname, appName, 'sasjsbuild');
171
- originalFilePath = path_1.default.join(buildPath, relativePath);
172
- destinationFilePath = path_1.default.join(buildPath, 'tests', relativePath);
173
- return [4 /*yield*/, (0, utils_1.createFile)(originalFilePath, testBody)];
174
- case 1:
175
- _a.sent();
176
- return [4 /*yield*/, (0, compileTestFile_1.moveTestFile)(originalFilePath)];
177
- case 2:
178
- _a.sent();
179
- return [4 /*yield*/, expect((0, utils_1.fileExists)(originalFilePath)).resolves.toEqual(false)];
180
- case 3:
181
- _a.sent();
182
- return [4 /*yield*/, expect((0, utils_1.fileExists)(destinationFilePath)).resolves.toEqual(true)];
183
- case 4:
184
- _a.sent();
185
- return [4 /*yield*/, expect((0, utils_1.readFile)(destinationFilePath)).resolves.toEqual(testBody)];
186
- case 5:
187
- _a.sent();
188
- return [2 /*return*/];
189
- }
190
- });
191
- }); });
192
- it('should move job test', function () { return __awaiter(void 0, void 0, void 0, function () {
193
- var relativePath, buildPath, originalFilePath, destinationFilePath;
194
- return __generator(this, function (_a) {
195
- switch (_a.label) {
196
- case 0:
197
- relativePath = path_1.default.join('jobs', 'jobs', testFileName);
198
- buildPath = path_1.default.join(__dirname, appName, 'sasjsbuild');
199
- originalFilePath = path_1.default.join(buildPath, relativePath);
200
- destinationFilePath = path_1.default.join(buildPath, 'tests', relativePath);
201
- return [4 /*yield*/, (0, utils_1.createFile)(originalFilePath, testBody)];
202
- case 1:
203
- _a.sent();
204
- return [4 /*yield*/, (0, compileTestFile_1.moveTestFile)(originalFilePath)];
205
- case 2:
206
- _a.sent();
207
- return [4 /*yield*/, expect((0, utils_1.fileExists)(originalFilePath)).resolves.toEqual(false)];
208
- case 3:
209
- _a.sent();
210
- return [4 /*yield*/, expect((0, utils_1.fileExists)(destinationFilePath)).resolves.toEqual(true)];
211
- case 4:
212
- _a.sent();
213
- return [4 /*yield*/, expect((0, utils_1.readFile)(destinationFilePath)).resolves.toEqual(testBody)];
214
- case 5:
215
- _a.sent();
216
- return [2 /*return*/];
217
- }
218
- });
219
- }); });
220
- });
221
163
  describe('compileTestFlow', function () {
222
164
  it('should compile test flow', function () { return __awaiter(void 0, void 0, void 0, function () {
223
165
  var testSetUp, testTearDown, testFlowPath, expectedTestFlow, _a, _b, _c;
@@ -46,12 +46,13 @@ var file_1 = require("../../../utils/file");
46
46
  function executeNonSasScript(scriptPath) {
47
47
  var _a, _b, _c, _d, _e;
48
48
  return __awaiter(this, void 0, void 0, function () {
49
- var fileExtension, logPath;
49
+ var fileExtension, buildDestinationResultsLogsFolder, logPath;
50
50
  return __generator(this, function (_f) {
51
51
  switch (_f.label) {
52
52
  case 0:
53
53
  fileExtension = path_1.default.extname(scriptPath);
54
- logPath = path_1.default.join(process.projectDir, 'sasjsbuild', path_1.default.basename(scriptPath).replace(fileExtension, '.log'));
54
+ buildDestinationResultsLogsFolder = process.sasjsConstants.buildDestinationResultsLogsFolder;
55
+ logPath = path_1.default.join(buildDestinationResultsLogsFolder, path_1.default.basename(scriptPath).replace(fileExtension, '.log'));
55
56
  if (!(0, file_1.isShellScript)(scriptPath)) return [3 /*break*/, 2];
56
57
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Executing shell script ".concat(scriptPath, " ..."));
57
58
  return [4 /*yield*/, (0, utils_1.executeShellScript)(scriptPath, logPath)];
@@ -233,7 +233,7 @@ describe('deploy', function () {
233
233
  case 1:
234
234
  _a.sent();
235
235
  expect(process.logger.info).toHaveBeenCalledWith("Executing shell script ".concat(path_1.default.join(process.projectDir, "script.sh"), " ..."));
236
- expect(process.logger.success).toHaveBeenCalledWith("Shell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationFolder, 'script.log')));
236
+ expect(process.logger.success).toHaveBeenCalledWith("Shell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationResultsLogsFolder, 'script.log')));
237
237
  return [2 /*return*/];
238
238
  }
239
239
  });
@@ -253,7 +253,7 @@ describe('deploy', function () {
253
253
  case 1:
254
254
  _a.sent();
255
255
  expect(process.logger.info).toHaveBeenCalledWith("Executing shell script ".concat(path_1.default.join(process.projectDir, "script.bat"), " ..."));
256
- expect(process.logger.success).toHaveBeenCalledWith("Shell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationFolder, 'script.log')));
256
+ expect(process.logger.success).toHaveBeenCalledWith("Shell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationResultsLogsFolder, 'script.log')));
257
257
  return [2 /*return*/];
258
258
  }
259
259
  });
@@ -273,7 +273,7 @@ describe('deploy', function () {
273
273
  case 1:
274
274
  _a.sent();
275
275
  expect(process.logger.info).toHaveBeenCalledWith("Executing powershell script ".concat(path_1.default.join(process.projectDir, "script.ps1"), " ..."));
276
- expect(process.logger.success).toHaveBeenCalledWith("PowerShell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationFolder, 'script.log')));
276
+ expect(process.logger.success).toHaveBeenCalledWith("PowerShell script execution completed! Log is here: ".concat(path_1.default.join(process.sasjsConstants.buildDestinationResultsLogsFolder, 'script.log')));
277
277
  return [2 /*return*/];
278
278
  }
279
279
  });
@@ -126,6 +126,11 @@ describe('FSCommand', function () {
126
126
  jest
127
127
  .spyOn(FileModule, 'createFile')
128
128
  .mockImplementation(function () { return Promise.resolve(); });
129
+ jest
130
+ .spyOn(configUtils, 'findTargetInConfiguration')
131
+ .mockImplementation(function () {
132
+ return Promise.resolve({ target: target, isLocal: true });
133
+ });
129
134
  return [4 /*yield*/, executeCommandWrapper([
130
135
  'compile',
131
136
  'localFolder',
@@ -147,6 +152,11 @@ describe('FSCommand', function () {
147
152
  jest
148
153
  .spyOn(FileModule, 'createFile')
149
154
  .mockImplementation(function () { return Promise.reject(); });
155
+ jest
156
+ .spyOn(configUtils, 'findTargetInConfiguration')
157
+ .mockImplementation(function () {
158
+ return Promise.resolve({ target: target, isLocal: true });
159
+ });
150
160
  return [4 /*yield*/, executeCommandWrapper(['compile', 'localFolder'])];
151
161
  case 1:
152
162
  returnCode = _a.sent();
@@ -1,15 +1,10 @@
1
- export function createFolderStructure(folder: any, parentFolderName?: string): Promise<void>;
2
- export function unifyFilePath(filePath: any, separator?: "\\" | "/", replace?: string): any;
3
- export function isSasFile(filePath: any): boolean;
4
- export function isJsonFile(filePath: any): boolean;
5
- export function isCsvFile(filePath: any): boolean;
6
- export function isShellScript(filePath: any): boolean;
7
- export function isPowerShellScript(filePath: any): boolean;
8
- export function getBrief(fileContent: any): any;
9
- export function getRelativePath(from: any, to: any): any[];
10
- export function saveToDefaultLocation(filePath: any, data: any): Promise<{
11
- absolutePath: string;
12
- relativePath: string;
13
- }>;
14
- export function sanitizeFileName(fileName: any): any;
15
- export const sasFileRegExp: RegExp;
1
+ import { Folder } from '../types';
2
+ export declare function createFolderStructure(folder: Folder, parentFolderName?: string): Promise<void>;
3
+ export declare function isSasFile(filePath: string): boolean;
4
+ export declare function isJsonFile(filePath: string): boolean;
5
+ export declare function isCsvFile(filePath: string): boolean;
6
+ export declare function isShellScript(filePath: string): boolean;
7
+ export declare function isPowerShellScript(filePath: string): boolean;
8
+ export declare const sanitizeFileName: (fileName: string) => string;
9
+ export declare function getBrief(fileContent: string): string | undefined;
10
+ export declare const sasFileRegExp: RegExp;
@@ -39,10 +39,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.sasFileRegExp = exports.saveToDefaultLocation = exports.getRelativePath = exports.getBrief = exports.sanitizeFileName = exports.isPowerShellScript = exports.isShellScript = exports.isCsvFile = exports.isJsonFile = exports.isSasFile = exports.unifyFilePath = exports.createFolderStructure = void 0;
42
+ exports.sasFileRegExp = exports.getBrief = exports.sanitizeFileName = exports.isPowerShellScript = exports.isShellScript = exports.isCsvFile = exports.isJsonFile = exports.isSasFile = exports.createFolderStructure = void 0;
43
43
  var path_1 = __importDefault(require("path"));
44
+ var chalk_1 = __importDefault(require("chalk"));
44
45
  var utils_1 = require("@sasjs/utils");
45
- var config_1 = require("./config");
46
+ var displayResult_1 = require("./displayResult");
46
47
  function createFolderStructure(folder, parentFolderName) {
47
48
  if (parentFolderName === void 0) { parentFolderName = '.'; }
48
49
  return __awaiter(this, void 0, void 0, function () {
@@ -65,7 +66,7 @@ function createFolderStructure(folder, parentFolderName) {
65
66
  switch (_a.label) {
66
67
  case 0:
67
68
  filePath = path_1.default.join(process.projectDir, parentFolderName, "".concat(folder.folderName, "/").concat(file.fileName));
68
- return [4 /*yield*/, (0, utils_1.createFile)(filePath, file.content).catch(function () {
69
+ return [4 /*yield*/, (0, utils_1.createFile)(filePath, file.content || '').catch(function () {
69
70
  var _a;
70
71
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Error creating file: ', filePath);
71
72
  })];
@@ -96,19 +97,6 @@ function createFolderStructure(folder, parentFolderName) {
96
97
  });
97
98
  }
98
99
  exports.createFolderStructure = createFolderStructure;
99
- function unifyFilePath(filePath, separator, replace) {
100
- if (separator === void 0) { separator = path_1.default.sep; }
101
- if (replace === void 0) { replace = '/'; }
102
- var separators = { unix: '/', win: '\\' };
103
- var osSeparator = Object.keys(separators).find(function (key) { return separators[key] === separator; });
104
- if (osSeparator) {
105
- var notValidSeparator = separators[Object.keys(separators).find(function (key) { return key !== osSeparator; })];
106
- osSeparator = separators[osSeparator];
107
- return filePath.split(notValidSeparator).join(osSeparator);
108
- }
109
- return filePath.split(replace).join(separator);
110
- }
111
- exports.unifyFilePath = unifyFilePath;
112
100
  function isSasFile(filePath) {
113
101
  return path_1.default.extname(filePath) === '.sas';
114
102
  }
@@ -134,74 +122,19 @@ var sanitizeFileName = function (fileName) {
134
122
  };
135
123
  exports.sanitizeFileName = sanitizeFileName;
136
124
  function getBrief(fileContent) {
137
- var fileHeader;
138
125
  try {
139
126
  var hasFileHeader = fileContent.split('/**')[0] !== fileContent;
140
127
  if (!hasFileHeader)
141
- return [];
142
- fileHeader = fileContent.split('/**')[1].split('**/')[0];
128
+ return;
129
+ var fileHeader = fileContent.split('/**')[1].split('**/')[0];
130
+ var lines = fileHeader.split('\n').map(function (s) { return (s ? s.trim() : s); });
131
+ var brief = lines.find(function (l) { return l.startsWith('@brief'); });
132
+ if (brief)
133
+ return brief.replace(/\@brief/g, '').trim();
143
134
  }
144
135
  catch (e) {
145
- console.error(chalk.redBright('File header parse error.\nPlease make sure your file header is in the correct format.'));
136
+ (0, displayResult_1.displayError)(e, chalk_1.default.redBright('File header parse error.\nPlease make sure your file header is in the correct format.'));
146
137
  }
147
- var lines = fileHeader.split('\n').map(function (s) { return (s ? s.trim() : s); });
148
- var brief = lines.find(function (l) { return l.startsWith('@brief'); });
149
- if (brief)
150
- brief = brief.replace(/\@brief/g, '').trim();
151
- return brief;
152
138
  }
153
139
  exports.getBrief = getBrief;
154
- function getRelativePath(from, to) {
155
- var fromFolders = from.split(path_1.default.sep);
156
- var toFolders = to.split(path_1.default.sep);
157
- var similarPath = [];
158
- var relativePath = [];
159
- fromFolders.forEach(function (fromFolder, i) {
160
- if (toFolders[i] !== undefined && fromFolders[i] === toFolders[i]) {
161
- similarPath.push(fromFolder);
162
- }
163
- else {
164
- if (fromFolder)
165
- relativePath.push(fromFolder);
166
- }
167
- });
168
- similarPath = similarPath.join(path_1.default.sep);
169
- var leadingPathSepRegExp = new RegExp("^".concat(path_1.default.sep.replace(/\\/g, '\\\\')));
170
- var trailingPathSepRegExp = new RegExp("".concat(path_1.default.sep.replace(/\\/g, '\\\\'), "$"));
171
- relativePath =
172
- (!path_1.default.sep.match(/\\/)
173
- ? relativePath.length
174
- ? "..".concat(path_1.default.sep).repeat(relativePath.length)
175
- : ".".concat(path_1.default.sep)
176
- : '') +
177
- to
178
- .replace(similarPath, '')
179
- .replace(leadingPathSepRegExp, '')
180
- .replace(trailingPathSepRegExp, '');
181
- return relativePath;
182
- }
183
- exports.getRelativePath = getRelativePath;
184
- function saveToDefaultLocation(filePath, data) {
185
- return __awaiter(this, void 0, void 0, function () {
186
- var root, destination, relativePath;
187
- return __generator(this, function (_a) {
188
- switch (_a.label) {
189
- case 0: return [4 /*yield*/, (0, config_1.getProjectRoot)()];
190
- case 1:
191
- root = _a.sent();
192
- destination = path_1.default.join(root, 'sasjsbuild', filePath);
193
- getRelativePath(process.cwd(), destination);
194
- relativePath = getRelativePath(process.cwd(), destination);
195
- return [4 /*yield*/, (0, utils_1.createFile)(destination, data)];
196
- case 2:
197
- _a.sent();
198
- return [2 /*return*/, Promise.resolve({
199
- absolutePath: destination,
200
- relativePath: "".concat(relativePath)
201
- })];
202
- }
203
- });
204
- });
205
- }
206
- exports.saveToDefaultLocation = saveToDefaultLocation;
207
140
  exports.sasFileRegExp = /.sas$/i;
@@ -87,32 +87,4 @@ describe('file utility', function () {
87
87
  });
88
88
  }); });
89
89
  });
90
- describe('unifyFilePath', function () {
91
- it('should unify file path in Unix-like systems', function () {
92
- var filePath = '/folder/subFolder/file.txt';
93
- expect((0, utils_1.unifyFilePath)(filePath, '/')).toEqual(filePath);
94
- });
95
- it('should unify file path in Windows system', function () {
96
- var filePath = '/folder/subFolder/file.txt';
97
- var expectedFilePath = filePath.replace(/\//g, '\\');
98
- expect((0, utils_1.unifyFilePath)(filePath, '\\')).toEqual(expectedFilePath);
99
- });
100
- it('should unify file path with mixed separators', function () {
101
- var filePath = '/folder/subFolder\\file.txt';
102
- var unixSeparator = '/';
103
- var winSeparator = '\\';
104
- var expectedUnixPath = filePath.replace(/\\/g, unixSeparator);
105
- var expectedWinPath = filePath.replace(/\//g, winSeparator);
106
- expect((0, utils_1.unifyFilePath)(filePath, unixSeparator)).toEqual(expectedUnixPath);
107
- expect((0, utils_1.unifyFilePath)(filePath, winSeparator)).toEqual(expectedWinPath);
108
- });
109
- it('should return file path with custom separator', function () {
110
- var filePath = '/folder/subFolder/file.txt';
111
- var expectedFilePath = filePath.replace(/\//g, '$');
112
- expect((0, utils_1.unifyFilePath)(filePath, '$')).toEqual(expectedFilePath);
113
- filePath = '\\folder\\subFolder\\file.txt';
114
- expectedFilePath = filePath.replace(/\\/g, '$');
115
- expect((0, utils_1.unifyFilePath)(filePath, '$', '\\')).toEqual(expectedFilePath);
116
- });
117
- });
118
90
  });
package/package.json CHANGED
@@ -102,5 +102,5 @@
102
102
  "typescript": "4.9.5",
103
103
  "util": "0.12.4"
104
104
  },
105
- "version": "4.0.1"
105
+ "version": "4.0.2"
106
106
  }