UNPKG

steadybit

Version:

Command-line interface to interact with the Steadybit API

40 lines 1.93 kB
"use strict"; // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2022 Steadybit GmbH 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 __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getExperiment = getExperiment; const js_yaml_1 = __importDefault(require("js-yaml")); const files_1 = require("./files"); const api_1 = require("./api"); function getExperiment(options) { return __awaiter(this, void 0, void 0, function* () { var _a; const experiment = yield (0, api_1.fetchExperiment)(options.key); const datatype = options.type ? options.type : ((_a = options.file) === null || _a === void 0 ? void 0 : _a.endsWith('.json')) ? 'json' : 'yaml'; if (!options.file) { if (datatype === 'json') { console.log(experiment); } else { console.log(js_yaml_1.default.dump(experiment)); } } else { yield (0, files_1.writeFile)(options.file, experiment, datatype); console.log('Experiment %s written to %s.', options.key, options.file); } }); } //# sourceMappingURL=get.js.map