UNPKG

@sasjs/cli

Version:

Command line interface for SASjs

572 lines (571 loc) 33.5 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FSCommand = void 0; var command_1 = require("../../types/command"); var targetCommand_1 = require("../../types/command/targetCommand"); var utils_1 = require("../../utils"); var path_1 = __importDefault(require("path")); var utils_2 = require("@sasjs/utils"); var executeCode_1 = require("./internal/executeCode"); var FsSubCommand; (function (FsSubCommand) { FsSubCommand["Compile"] = "compile"; FsSubCommand["Sync"] = "sync"; FsSubCommand["Deploy"] = "deploy"; })(FsSubCommand || (FsSubCommand = {})); var syntax = 'fs <subCommand> [options]'; var usage = 'Usage: sasjs fs <subCommand> [options]'; var description = 'Handles operations around file system synchronisation'; var parseOptions = { output: { type: 'string', alias: 'o' } }; var compileCommandSyntax = 'fs <subCommand> <local> [options]'; var compileCommandUsage = 'sasjs fs compile <localFolder> [options]'; var compileCommandDescription = 'Compiles a SAS program with the contents of a local directory'; var compileCommandExamples = [ { command: 'sasjs fs compile <path/of/folder> --output <path/of/outputProgram>', description: 'Compiles a SAS program with the contents of a local directory' } ]; var syncCommandSyntax = 'fs <subCommand> [options]'; var syncCommandUsage = 'sasjs fs sync'; var syncCommandDescription = 'Synchronise the remote SAS file system with the local project folder according to the target `syncDirectories` array'; var syncCommandExamples = [ { command: 'sasjs fs sync --local <path/of/folder> --remote <path/of/remote/folder>', description: '' }, { command: 'sasjs fs sync --local <path/of/folder> --remote <path/of/remote/folder> --target <target-name>', description: '' }, { command: 'sasjs fs sync -l <path/of/folder> -r <path/of/remote/folder> -t <target-name>', description: '' } ]; var syncCommandParseOptions = __assign(__assign({}, parseOptions), { local: { type: 'string', alias: 'l' }, remote: { type: 'string', alias: 'r' } }); var deployCommandSyntax = 'fs <subCommand> <local> <remote> [options]'; var deployCommandUsage = 'sasjs fs deploy <localFolder> <remoteFolder> [options]'; var deployCommandDescription = 'Compiles and deploys a local directory tree with one on a remote SAS server.'; var deployCommandExamples = [ { command: 'sasjs fs deploy <path/of/folder> --output <path/of/outputProgram>', description: 'deploys a SAS program with the contents of a local directory' } ]; var FSCommand = /** @class */ (function (_super) { __extends(FSCommand, _super); function FSCommand(args) { var commandOptions = { syntax: syntax, usage: usage, description: description, parseOptions: parseOptions }; var subCommand = args[3]; switch (subCommand) { case FsSubCommand.Compile: commandOptions.syntax = compileCommandSyntax; commandOptions.usage = compileCommandUsage; commandOptions.description = compileCommandDescription; commandOptions.examples = compileCommandExamples; break; case FsSubCommand.Deploy: commandOptions.syntax = deployCommandSyntax; commandOptions.usage = deployCommandUsage; commandOptions.description = deployCommandDescription; commandOptions.examples = deployCommandExamples; break; case FsSubCommand.Sync: commandOptions.syntax = syncCommandSyntax; commandOptions.usage = syncCommandUsage; commandOptions.description = syncCommandDescription; commandOptions.examples = syncCommandExamples; commandOptions.parseOptions = syncCommandParseOptions; break; } return _super.call(this, args, commandOptions) || this; } Object.defineProperty(FSCommand.prototype, "localFolder", { get: function () { var _a; var sourcePath = (_a = this.parsed.local) !== null && _a !== void 0 ? _a : ''; var currentDirPath = path_1.default.isAbsolute(sourcePath) ? '' : process.projectDir; return path_1.default.join(currentDirPath, sourcePath); }, enumerable: false, configurable: true }); Object.defineProperty(FSCommand.prototype, "remoteFolder", { get: function () { var _a; var remotePath = (_a = this.parsed.remote) !== null && _a !== void 0 ? _a : ''; return remotePath.endsWith(path_1.default.sep) ? remotePath.slice(0, -1) : remotePath; }, enumerable: false, configurable: true }); FSCommand.prototype.getOutputPath = function () { return __awaiter(this, void 0, void 0, function () { var outputPath, outputFolder, filename; return __generator(this, function (_a) { outputPath = this.parsed.output; if (this.parsed.subCommand === FsSubCommand.Compile) { if (!outputPath) { outputFolder = path_1.default.join(process.sasjsConstants.buildDestinationFolder, 'fs-compile', (0, utils_2.generateTimestamp)()); filename = 'compileProgram.sas'; return [2 /*return*/, path_1.default.join(outputFolder, filename)]; } if (!outputPath.endsWith('.sas')) { outputPath += '.sas'; } } if (!outputPath) { return [2 /*return*/, path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, "fs-".concat(this.parsed.subCommand), (0, utils_2.generateTimestamp)())]; } if (path_1.default.isAbsolute(outputPath)) { return [2 /*return*/, path_1.default.join(outputPath, (0, utils_2.generateTimestamp)())]; } return [2 /*return*/, path_1.default.join(process.cwd(), outputPath, (0, utils_2.generateTimestamp)())]; }); }); }; FSCommand.prototype.execute = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: if (!(this.parsed.subCommand === FsSubCommand.Compile)) return [3 /*break*/, 2]; return [4 /*yield*/, this.compile()]; case 1: return [2 /*return*/, _a.sent()]; case 2: if (!(this.parsed.subCommand === FsSubCommand.Deploy)) return [3 /*break*/, 4]; return [4 /*yield*/, this.deploy()]; case 3: return [2 /*return*/, _a.sent()]; case 4: if (!(this.parsed.subCommand === FsSubCommand.Sync)) return [3 /*break*/, 6]; return [4 /*yield*/, this.sync()]; case 5: return [2 /*return*/, _a.sent()]; case 6: return [2 /*return*/, command_1.ReturnCode.InvalidCommand]; } }); }); }; FSCommand.prototype.compile = function () { return __awaiter(this, void 0, void 0, function () { var folderPath, outputPath, programContent; return __generator(this, function (_a) { switch (_a.label) { case 0: // NOTE: call getTargetInfo() method once, so that process.sasjsConstants could be updated based on target config return [4 /*yield*/, this.getTargetInfo()]; case 1: // NOTE: call getTargetInfo() method once, so that process.sasjsConstants could be updated based on target config _a.sent(); folderPath = this.localFolder; return [4 /*yield*/, this.getOutputPath()]; case 2: outputPath = _a.sent(); return [4 /*yield*/, (0, utils_2.generateCompileProgram)(folderPath)]; case 3: programContent = _a.sent(); return [4 /*yield*/, (0, utils_2.createFile)(outputPath, programContent) .then(function () { var _a; (_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("A compiled sas program has been successfully created at ".concat(outputPath)); return command_1.ReturnCode.Success; }) .catch(function (err) { (0, utils_1.displayError)(err, 'An error has occurred when creating program file.'); return command_1.ReturnCode.InternalError; })]; case 4: return [2 /*return*/, _a.sent()]; } }); }); }; FSCommand.prototype.deploy = function () { var _a, _b, _c, _d, _e; return __awaiter(this, void 0, void 0, function () { var target, remoteFolderPath, localFolderPath, outputFolder, code, program, error_1, logPath; var _this = this; return __generator(this, function (_f) { switch (_f.label) { case 0: return [4 /*yield*/, this.getTargetInfo()]; case 1: target = (_f.sent()).target; remoteFolderPath = this.remoteFolder; localFolderPath = this.localFolder; return [4 /*yield*/, this.getOutputPath()]; case 2: outputFolder = _f.sent(); _f.label = 3; case 3: _f.trys.push([3, 7, , 9]); (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info('generating compile program'); return [4 /*yield*/, (0, utils_2.generateCompileProgram)(localFolderPath)]; case 4: code = _f.sent(); (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info('setting fsTaregt at the start of compiled program'); program = "%let fsTarget=".concat((0, utils_2.generatePathForSas)(remoteFolderPath), ";\n").concat(code); return [4 /*yield*/, createProgramFile(program, path_1.default.join(outputFolder, 'deploy.sas'))]; case 5: _f.sent(); (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info('executing program to deploy a local directory tree'); return [4 /*yield*/, (0, executeCode_1.executeCode)(target, program).then(function (_a) { var log = _a.log; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { switch (_b.label) { case 0: return [4 /*yield*/, (0, utils_1.saveLog)(log, path_1.default.join(outputFolder, 'deploy.log'), '', false)]; case 1: _b.sent(); return [2 /*return*/]; } }); }); })]; case 6: _f.sent(); (_d = process.logger) === null || _d === void 0 ? void 0 : _d.success("A local directory tree has been successfully deployed to remote sas server"); return [2 /*return*/, command_1.ReturnCode.Success]; case 7: error_1 = _f.sent(); logPath = path_1.default.join(outputFolder, 'error.log'); return [4 /*yield*/, createErrorLogFile(error_1, logPath)]; case 8: _f.sent(); (_e = process.logger) === null || _e === void 0 ? void 0 : _e.error("An error has occurred. For more info see ".concat(logPath)); return [2 /*return*/, command_1.ReturnCode.InternalError]; case 9: return [2 /*return*/]; } }); }); }; FSCommand.prototype.sync = function () { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; return __awaiter(this, void 0, void 0, function () { var _o, target, isLocal, remoteFolderPath, localFolderPath, syncDirectories, _p, _q, _r, _s, _loop_1, this_1, syncDirectories_1, syncDirectories_1_1, obj, state_1, e_1_1; var e_1, _t; return __generator(this, function (_u) { switch (_u.label) { case 0: return [4 /*yield*/, this.getTargetInfo()]; case 1: _o = _u.sent(), target = _o.target, isLocal = _o.isLocal; remoteFolderPath = this.remoteFolder; localFolderPath = this.localFolder; syncDirectories = []; if (!(remoteFolderPath && localFolderPath)) return [3 /*break*/, 2]; syncDirectories.push({ remote: remoteFolderPath, local: localFolderPath }); return [3 /*break*/, 4]; case 2: _q = (_p = syncDirectories.push).apply; _r = [syncDirectories]; _s = [[]]; return [4 /*yield*/, (0, utils_1.getSyncDirectories)(target, isLocal)]; case 3: _q.apply(_p, _r.concat([__spreadArray.apply(void 0, _s.concat([__read.apply(void 0, [(_u.sent())]), false]))])); _u.label = 4; case 4: if (!syncDirectories.length) { (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info('There are no directories to sync.'); return [2 /*return*/, command_1.ReturnCode.Success]; } _loop_1 = function (obj) { var outputFolder, program, log, remoteHashes, localHash, remoteHashMap_1, hashedDiff, syncProgram, syncLog, syncedHash, syncedHashMap, syncedResources_1, resourcesNotPresentLocally, error_2, logPath; return __generator(this, function (_v) { switch (_v.label) { case 0: return [4 /*yield*/, this_1.getOutputPath()]; case 1: outputFolder = _v.sent(); _v.label = 2; case 2: _v.trys.push([2, 15, , 17]); (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info('generating program to get remote hash'); return [4 /*yield*/, (0, utils_2.generateProgramToGetRemoteHash)(obj.remote)]; case 3: program = _v.sent(); return [4 /*yield*/, createProgramFile(program, path_1.default.join(outputFolder, 'getRemoteHash.sas'))]; case 4: _v.sent(); (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info('executing program to get remote hash'); return [4 /*yield*/, (0, executeCode_1.executeCode)(target, program)]; case 5: log = (_v.sent()).log; return [4 /*yield*/, (0, utils_1.saveLog)(log, path_1.default.join(outputFolder, 'getRemoteHash.log'), '', false)]; case 6: _v.sent(); (_d = process.logger) === null || _d === void 0 ? void 0 : _d.info('extracting hashes from log'); remoteHashes = (0, utils_2.extractHashArray)(log); return [4 /*yield*/, createHashFile(JSON.stringify(remoteHashes, null, 2), path_1.default.join(outputFolder, 'hashesBeforeSync.json'))]; case 7: _v.sent(); (_e = process.logger) === null || _e === void 0 ? void 0 : _e.info('creating the hash of local folder'); return [4 /*yield*/, (0, utils_2.getHash)((0, utils_2.getAbsolutePath)(obj.local, process.projectDir))]; case 8: localHash = _v.sent(); remoteHashMap_1 = remoteHashes.reduce(function (map, item) { var from = obj.remote.replace(/\//g, path_1.default.sep); var to = item.FILE_PATH.replace(/\//g, path_1.default.sep); var relativePath = (0, utils_2.getRelativePath)(from, to); map[relativePath] = item.FILE_HASH; return map; }, {}); if (remoteHashMap_1[localHash.relativePath] === localHash.hash) { (_f = process.logger) === null || _f === void 0 ? void 0 : _f.info('There are no differences between Remote and Local directory. Already synced.'); return [2 /*return*/, { value: command_1.ReturnCode.Success }]; } (_g = process.logger) === null || _g === void 0 ? void 0 : _g.info('Extract differences from local and remote hash'); hashedDiff = (0, utils_2.compareHashes)(localHash, remoteHashMap_1); return [4 /*yield*/, createHashFile(JSON.stringify(hashedDiff, null, 2), path_1.default.join(outputFolder, 'hashesDiff.json'))]; case 9: _v.sent(); (_h = process.logger) === null || _h === void 0 ? void 0 : _h.info('generating program to sync differences'); return [4 /*yield*/, (0, utils_2.generateProgramToSyncHashDiff)(hashedDiff, obj.remote)]; case 10: syncProgram = _v.sent(); return [4 /*yield*/, createProgramFile(syncProgram, path_1.default.join(outputFolder, 'syncProgram.sas'))]; case 11: _v.sent(); (_j = process.logger) === null || _j === void 0 ? void 0 : _j.info('executing program to sync differences'); return [4 /*yield*/, (0, executeCode_1.executeCode)(target, syncProgram)]; case 12: syncLog = (_v.sent()).log; return [4 /*yield*/, (0, utils_1.saveLog)(syncLog, path_1.default.join(outputFolder, 'sync.log'), '', false)]; case 13: _v.sent(); syncedHash = (0, utils_2.extractHashArray)(syncLog); return [4 /*yield*/, createHashFile(JSON.stringify(syncedHash, null, 2), path_1.default.join(outputFolder, 'hashesAfterSync.json'))]; case 14: _v.sent(); syncedHashMap = syncedHash.reduce(function (map, item) { var from = obj.remote.replace(/\//g, path_1.default.sep); var to = item.FILE_PATH.replace(/\//g, path_1.default.sep); var relativePath = (0, utils_2.getRelativePath)(from, to); map[relativePath] = item.FILE_HASH; return map; }, {}); syncedResources_1 = []; Object.entries(syncedHashMap).forEach(function (_a) { var _b = __read(_a, 2), key = _b[0], value = _b[1]; if (remoteHashMap_1[key] !== value) syncedResources_1.push(key); }); if (syncedResources_1.length) { (_k = process.logger) === null || _k === void 0 ? void 0 : _k.log("The following resources were synced to: ".concat(obj.remote)); syncedResources_1.forEach(function (item) { var _a; (_a = process.logger) === null || _a === void 0 ? void 0 : _a.log("* ".concat(item)); }); } resourcesNotPresentLocally = (0, utils_2.findResourcesNotPresentLocally)(localHash, syncedHashMap); if (resourcesNotPresentLocally.length) { (_l = process.logger) === null || _l === void 0 ? void 0 : _l.log('The following resources are present in remote directory but not in local:'); resourcesNotPresentLocally.forEach(function (item) { var _a; (_a = process.logger) === null || _a === void 0 ? void 0 : _a.log("* ".concat(item)); }); } return [3 /*break*/, 17]; case 15: error_2 = _v.sent(); logPath = path_1.default.join(outputFolder, 'error.log'); return [4 /*yield*/, createErrorLogFile(error_2, logPath)]; case 16: _v.sent(); (_m = process.logger) === null || _m === void 0 ? void 0 : _m.error("An error has occurred. For more info see ".concat(logPath)); return [2 /*return*/, { value: command_1.ReturnCode.InternalError }]; case 17: return [2 /*return*/]; } }); }; this_1 = this; _u.label = 5; case 5: _u.trys.push([5, 10, 11, 12]); syncDirectories_1 = __values(syncDirectories), syncDirectories_1_1 = syncDirectories_1.next(); _u.label = 6; case 6: if (!!syncDirectories_1_1.done) return [3 /*break*/, 9]; obj = syncDirectories_1_1.value; return [5 /*yield**/, _loop_1(obj)]; case 7: state_1 = _u.sent(); if (typeof state_1 === "object") return [2 /*return*/, state_1.value]; _u.label = 8; case 8: syncDirectories_1_1 = syncDirectories_1.next(); return [3 /*break*/, 6]; case 9: return [3 /*break*/, 12]; case 10: e_1_1 = _u.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 12]; case 11: try { if (syncDirectories_1_1 && !syncDirectories_1_1.done && (_t = syncDirectories_1.return)) _t.call(syncDirectories_1); } finally { if (e_1) throw e_1.error; } return [7 /*endfinally*/]; case 12: return [2 /*return*/, command_1.ReturnCode.Success]; } }); }); }; return FSCommand; }(targetCommand_1.TargetCommand)); exports.FSCommand = FSCommand; var createHashFile = function (content, fileName) { return __awaiter(void 0, void 0, void 0, function () { var _a, _b; return __generator(this, function (_c) { switch (_c.label) { case 0: (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Creating json file at ".concat(fileName, " .")); return [4 /*yield*/, (0, utils_2.createFile)(fileName, content)]; case 1: _c.sent(); (_b = process.logger) === null || _b === void 0 ? void 0 : _b.success("Hashes saved to ".concat(fileName, " .")); return [2 /*return*/]; } }); }); }; var createProgramFile = function (program, fileName) { return __awaiter(void 0, void 0, void 0, function () { var _a, _b; return __generator(this, function (_c) { switch (_c.label) { case 0: (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Creating program file at ".concat(fileName, " .")); return [4 /*yield*/, (0, utils_2.createFile)(fileName, program)]; case 1: _c.sent(); (_b = process.logger) === null || _b === void 0 ? void 0 : _b.success("Program saved to ".concat(fileName, " .")); return [2 /*return*/]; } }); }); }; var createErrorLogFile = function (error, logPath) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: if (!error.log) return [3 /*break*/, 2]; return [4 /*yield*/, (0, utils_2.createFile)(logPath, error.log)]; case 1: return [2 /*return*/, _a.sent()]; case 2: if (!(error instanceof Error)) return [3 /*break*/, 4]; return [4 /*yield*/, (0, utils_2.createFile)(logPath, error.toString())]; case 3: return [2 /*return*/, _a.sent()]; case 4: if (!(typeof error === 'object')) return [3 /*break*/, 6]; return [4 /*yield*/, (0, utils_2.createFile)(logPath, JSON.stringify(error, null, 2))]; case 5: return [2 /*return*/, _a.sent()]; case 6: return [4 /*yield*/, (0, utils_2.createFile)(logPath, error)]; case 7: _a.sent(); return [2 /*return*/]; } }); }); };