1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Exclude node_modules directory

This commit is contained in:
Ted John
2020-02-06 21:55:53 +00:00
parent f9d7237e92
commit 2e62078c30
2 changed files with 19 additions and 9 deletions

View File

@@ -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)

View File

@@ -127,6 +127,7 @@ namespace OpenRCT2::Scripting
void Initialise();
void LoadPlugins();
void StartPlugins();
bool ShouldLoadScript(const std::string& path);
void AutoReloadPlugins();
};
} // namespace OpenRCT2::Scripting