function getAllHelper()

in src/PluginInfo/PluginInfoProvider.js [60:85]


function getAllHelper (absPath, provider) {
    if (!fs.existsSync(absPath)) {
        return [];
    }
    // If dir itself is a plugin, return it in an array with one element.
    if (fs.existsSync(path.join(absPath, 'plugin.xml'))) {
        return [provider.get(absPath)];
    }

    // Match normal and scoped plugins
    const pluginXmlPaths = fastGlob.sync('{,@*/}*/plugin.xml', {
        fs, // we pass in fs here, to be able to mock it in our tests
        cwd: absPath,
        onlyFiles: true,
        absolute: true
    }).map(path.normalize);

    return pluginXmlPaths.map(pluginXmlPath => {
        try {
            return provider.get(path.dirname(pluginXmlPath));
        } catch (err) {
            events.emit('warn', `Error parsing ${pluginXmlPath}:\n${err.stack}`);
            return null;
        }
    }).filter(p => p);
}