"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
const util_1 = require("../util");
const hook = async function ({ config }) {
    const plugins = await Promise.all(config.getPluginsList().map(async (p) => {
        if (p.valid)
            return;
        try {
            const plugin = new __1.PluginLegacy(config, p);
            await plugin.load();
            // Return the legacy plugin. @oclif/core will insert into the plugins array
            return plugin;
        }
        catch (error) {
            const err = error;
            err.name = `@oclif/plugin-legacy: Plugin ${p.name}: ${err.name}`;
            err.message = (0, util_1.compact)([err.message, p.root]).join(' ');
            process.emitWarning(err);
        }
    }));
    return plugins.filter(Boolean);
};
exports.default = hook;
