29 lines
4.6 KiB
JavaScript
29 lines
4.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const runtime_1 = require("../errors/runtime");
|
|
const types_1 = require("../errors/types");
|
|
class ReporterStreamController {
|
|
constructor(messageBus, reporters) {
|
|
this._pluginInfos = [];
|
|
this._messageBus = messageBus;
|
|
this.multipleStreamError = null;
|
|
reporters.forEach(({ plugin }) => {
|
|
plugin.streamController = this;
|
|
});
|
|
}
|
|
ensureUniqueStream(stream, plugin) {
|
|
const pluginInfo = this._pluginInfos.find(info => info.stream === stream);
|
|
if (!pluginInfo)
|
|
this._pluginInfos.push({ stream: stream, plugin: plugin });
|
|
else if (pluginInfo.plugin !== plugin) {
|
|
const message = [pluginInfo.plugin.name, plugin.name].join(', ');
|
|
this.multipleStreamError = new runtime_1.GeneralError(types_1.RUNTIME_ERRORS.multipleSameStreamReporters, message);
|
|
this._messageBus.emit('done');
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
exports.default = ReporterStreamController;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVwb3J0ZXItc3RyZWFtLWNvbnRyb2xsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcnVubmVyL3JlcG9ydGVyLXN0cmVhbS1jb250cm9sbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBRUEsK0NBQWlEO0FBQ2pELDJDQUFpRDtBQVNqRCxNQUFNLHdCQUF3QjtJQUsxQixZQUFvQixVQUF3QixFQUFFLFNBQXFCO1FBQy9ELElBQUksQ0FBQyxZQUFZLEdBQUcsRUFBRSxDQUFDO1FBQ3ZCLElBQUksQ0FBQyxXQUFXLEdBQUcsVUFBVSxDQUFDO1FBQzlCLElBQUksQ0FBQyxtQkFBbUIsR0FBRyxJQUFJLENBQUM7UUFFaEMsU0FBUyx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