1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | class CommandGroup {
|
12 | constructor(commands) {
|
13 | this.commands = commands;
|
14 | }
|
15 | static from(...commands) {
|
16 | return new CommandGroup(commands);
|
17 | }
|
18 | parallel(exec = cmd => cmd.exec()) {
|
19 | return Promise.all(this.commands.map(command => exec(command)));
|
20 | }
|
21 | serial(exec = cmd => cmd.exec()) {
|
22 | return this.commands.reduce((previous, command) => __awaiter(this, void 0, void 0, function* () {
|
23 | const results = yield previous;
|
24 | const result = yield exec(command);
|
25 | return results.concat(result);
|
26 | }), Promise.resolve([]));
|
27 | }
|
28 | }
|
29 | exports.CommandGroup = CommandGroup;
|
30 |
|
\ | No newline at end of file |