mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 07:43:01 +01:00
Exclude node_modules directory
This commit is contained in:
@@ -86,16 +86,19 @@ void ScriptEngine::LoadPlugins()
|
||||
while (scanner->Next())
|
||||
{
|
||||
auto path = std::string(scanner->GetPath());
|
||||
try
|
||||
if (ShouldLoadScript(path))
|
||||
{
|
||||
auto plugin = std::make_shared<Plugin>(_context, path);
|
||||
ScriptExecutionInfo::PluginScope scope(_execInfo, plugin);
|
||||
plugin->Load();
|
||||
_plugins.push_back(std::move(plugin));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
_console.WriteLineError(e.what());
|
||||
try
|
||||
{
|
||||
auto plugin = std::make_shared<Plugin>(_context, path);
|
||||
ScriptExecutionInfo::PluginScope scope(_execInfo, plugin);
|
||||
plugin->Load();
|
||||
_plugins.push_back(std::move(plugin));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
_console.WriteLineError(e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +117,12 @@ void ScriptEngine::LoadPlugins()
|
||||
}
|
||||
}
|
||||
|
||||
bool ScriptEngine::ShouldLoadScript(const std::string& path)
|
||||
{
|
||||
// A lot of JavaScript is often found in a node_modules directory tree and is most likely unwanted, so ignore it
|
||||
return path.find("/node_modules/") == std::string::npos && path.find("\\node_modules\\") == std::string::npos;
|
||||
}
|
||||
|
||||
void ScriptEngine::AutoReloadPlugins()
|
||||
{
|
||||
if (_changedPluginFiles.size() > 0)
|
||||
|
||||
@@ -127,6 +127,7 @@ namespace OpenRCT2::Scripting
|
||||
void Initialise();
|
||||
void LoadPlugins();
|
||||
void StartPlugins();
|
||||
bool ShouldLoadScript(const std::string& path);
|
||||
void AutoReloadPlugins();
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
Reference in New Issue
Block a user