function fix_munge()

in src/PlatformJson.js [205:230]


function fix_munge (root) {
    root.prepare_queue = root.prepare_queue || { installed: [], uninstalled: [] };
    root.config_munge = root.config_munge || { files: {} };
    root.installed_plugins = root.installed_plugins || {};
    root.dependent_plugins = root.dependent_plugins || {};

    const munge = root.config_munge;
    if (!munge.files) {
        const new_munge = { files: {} };

        for (const file in munge) {
            for (const selector in munge[file]) {
                for (const xml_child in munge[file][selector]) {
                    const val = parseInt(munge[file][selector][xml_child]);
                    for (let i = 0; i < val; i++) {
                        mungeutil.deep_add(new_munge, [file, selector, { xml: xml_child, count: val }]);
                    }
                }
            }
        }

        root.config_munge = new_munge;
    }

    return root;
}