strapi/packages/core/admin/utils/create-plugins-exclude-path.js

21 lines
653 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const NODE_MODULES = 'node_modules';
/**
* @param {string[]} pluginsPath an array of paths to the plugins from the user's directory
* @returns {RegExp} a regex that will exclude _all_ node_modules except for the plugins in the pluginsPath array.
*/
const createPluginsExcludePath = (pluginsPath = []) => {
/**
* If there aren't any plugins in the node_modules array, just return the node_modules regex
* without complicating it.
*/
if (pluginsPath.length === 0) {
return /node_modules/;
}
return new RegExp(`${NODE_MODULES}/(?!(${pluginsPath.join('|')}))`);
};
module.exports = { createPluginsExcludePath };