UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

54 lines 1.85 kB
"use strict"; /* * Copyright © 2019 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.WriteToAllProgressLog = void 0; const logger_1 = require("@atomist/automation-client/lib/util/logger"); /** * Write to multiple progress logs, exposing them as one. */ class WriteToAllProgressLog { constructor(name, log1, log2, ...others) { this.name = name; this.logs = [log1, log2].concat(others); } async isAvailable() { return true; } write(msg, ...args) { this.logs.forEach(log => log.write(msg, ...args)); } async flush() { await Promise.all(this.logs.map(log => log.flush())); } async close() { if (!this.logs) { logger_1.logger.error("This is unexpected! How did I get here without logs?"); return; } await Promise.all(this.logs.map(log => log.close())); } get log() { const hasLog = this.logs.find(l => l.log !== undefined); return !!hasLog ? hasLog.log : undefined; } get url() { const hasUrl = this.logs.find(l => !!l.url); return !!hasUrl ? hasUrl.url : undefined; } } exports.WriteToAllProgressLog = WriteToAllProgressLog; //# sourceMappingURL=WriteToAllProgressLog.js.map