/*
 * Copyright (C) 2016-2020 Kano Computing Ltd.
 * License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 */
export class PluginReceiver {
    constructor() {
        this.plugins = [];
    }
    addPlugin(plugin) {
        this.plugins.push(plugin);
    }
    runPluginTask(taskName, ...args) {
        this.plugins.forEach(plugin => plugin[taskName](...args));
    }
    runPluginChainTask(taskName, ...args) {
        return this.plugins.reduce((p, plugin) => {
            if (p instanceof Promise) {
                return p.then(() => plugin[taskName](...args));
            }
            return plugin[taskName](...args);
        }, Promise.resolve());
    }
}
export default PluginReceiver;
//# sourceMappingURL=receiver.js.map