File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -74,14 +74,21 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
7474 scriptEngine.eval (baseLibContent.value ());
7575
7676 // Load the plugin entry.
77- auto pluginDir = std::filesystem::canonical (ll::plugin::getPluginsRoot () / manifest.name );
78- auto entryPath = pluginDir / manifest.entry ;
79- auto pluginEntryContent = ll::file_utils::readFile (entryPath);
80- if (!pluginEntryContent) {
81- logger.error (" failed to read plugin entry at {}" , entryPath.string ());
82- return false ;
77+ auto pluginDir = std::filesystem::canonical (ll::plugin::getPluginsRoot () / manifest.name );
78+ auto entryPath = pluginDir / manifest.entry ;
79+
80+ // Try loadFile
81+ try {
82+ scriptEngine.loadFile (entryPath.u8string ());
83+ } catch (const script::Exception& e) {
84+ // loadFile failed, try eval
85+ auto pluginEntryContent = ll::file_utils::readFile (entryPath);
86+ if (!pluginEntryContent) {
87+ logger.error (" failed to read plugin entry at {}" , entryPath.string ());
88+ return false ;
89+ }
90+ scriptEngine.eval (pluginEntryContent.value ());
8391 }
84- scriptEngine.eval (pluginEntryContent.value ());
8592 plugin->onLoad ([](ll::plugin::Plugin& plugin) { return true ; });
8693 plugin->onUnload ([](ll::plugin::Plugin& plugin) { return true ; });
8794 plugin->onEnable ([](ll::plugin::Plugin& plugin) { return true ; });
You can’t perform that action at this time.
0 commit comments