@apideck/portman
Version:
Port OpenAPI Spec to Postman Collection, with contract & variation tests included
38 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = void 0;
var tslib_1 = require("tslib");
var chalk_1 = tslib_1.__importDefault(require("chalk"));
var fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
var path_1 = tslib_1.__importDefault(require("path"));
var PortmanConfig_parse_1 = require("../utils/PortmanConfig.parse");
var oas_1 = require("../oas");
var getConfig = function (configPath) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var config, oaf, _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
config = {};
oaf = new oas_1.OpenApiFormatter();
_a = configPath;
if (!_a) return [3, 2];
return [4, fs_extra_1.default.pathExists(path_1.default.resolve(configPath))];
case 1:
_a = (_b.sent());
_b.label = 2;
case 2:
if (!_a) return [3, 4];
return [4, oaf.parseFile(configPath)];
case 3:
config = (_b.sent());
_b.label = 4;
case 4:
if (Object.entries(config).length === 0) {
console.log(chalk_1.default.red("Portman config file not provided."));
}
return [2, (0, PortmanConfig_parse_1.parsePortmanConfig)(config)];
}
});
}); };
exports.getConfig = getConfig;
//# sourceMappingURL=getConfig.js.map