remove: function()

in src/plugman/platform.js [56:80]


    remove: function (platformName) {
        // Check to make sure we are in the plugin first
        if (!fs.existsSync('plugin.xml')) {
            return Promise.reject(new Error("can't find a plugin.xml.  Are you in the plugin?"));
        }

        // Get the current plugin.xml file
        const pluginxml = et.parse(fs.readFileSync('plugin.xml', 'utf-8'));

        // Check if this platform exists
        if (!pluginxml.find("./platform/[@name='" + platformName + "']")) {
            return Promise.reject(new Error('platform: ' + platformName + " hasn't been added"));
        }

        // Remove the Platform in question
        pluginxml.getroot().remove(pluginxml.find("./platform/[@name='" + platformName + "']"));

        // Rewrite the plugin.xml file back out
        fs.writeFileSync('plugin.xml', pluginxml.write('plugin.xml', { indent: 4 }), 'utf-8');

        // Remove the src/"platform"
        fs.removeSync(path.join('src', platformName));

        return Promise.resolve();
    }