UNPKG

1.57 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12exports.AbstractCollection = void 0;
13class AbstractCollection {
14 constructor(collection, runner) {
15 this.collection = collection;
16 this.runner = runner;
17 }
18 execute(name, options, extraFlags) {
19 return __awaiter(this, void 0, void 0, function* () {
20 let command = this.buildCommandLine(name, options);
21 command = extraFlags ? command.concat(` ${extraFlags}`) : command;
22 yield this.runner.run(command);
23 });
24 }
25 buildCommandLine(name, options) {
26 return `${this.collection}:${name}${this.buildOptions(options)}`;
27 }
28 buildOptions(options) {
29 return options.reduce((line, option) => {
30 return line.concat(` ${option.toCommandString()}`);
31 }, '');
32 }
33}
34exports.AbstractCollection = AbstractCollection;