mirror of
https://github.com/strapi/strapi.git
synced 2025-08-14 03:34:53 +00:00
21 lines
653 B
JavaScript
21 lines
653 B
JavaScript
'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 };
|