Skip to content

Commit e80acaf

Browse files
committed
fix: fix npm install
1 parent d1cfc47 commit e80acaf

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

src/legacy/main/NodeJsHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ int executeNpmCommand(std::string cmd, std::string workingDir) {
335335

336336
string executeJs = "const oldCwd = process.cwd();"
337337
"const publicRequire = require('module').createRequire(oldCwd + "
338-
"'/plugins/lib/');"
338+
"'/plugins/legacy-script-engine-nodejs/');"
339339
"require('process').chdir('"
340340
+ workingDir + "');" + "publicRequire('npm-js-interface')('" + cmd + "');"
341341
+ "require('process').chdir(oldCwd);";

src/lse/PluginManager.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,10 @@ PluginManager::PluginManager() : ll::plugin::PluginManager(PluginManagerName) {}
6363
auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
6464
auto& logger = getSelfPluginInstance().getLogger();
6565
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
66-
// "dirPath" is public temp dir (LLSE_PLUGIN_PACKAGE_TEMP_DIR) or normal
67-
// plugin dir "packagePath" will point to plugin package path if
68-
// isUncompressedFirstTime == true
69-
std::filesystem::path dirPath = ll::plugin::getPluginsRoot() / manifest.name;
70-
std::string entryPath = PythonHelper::findEntryScript(dirPath.string());
71-
if (entryPath.empty()) return false;
72-
std::string pluginName = PythonHelper::getPluginPackageName(dirPath.string());
66+
std::filesystem::path dirPath = ll::plugin::getPluginsRoot() / manifest.name; // Plugin path
67+
// std::string entryPath = PythonHelper::findEntryScript(dirPath.string()); // Plugin entry
68+
// if (entryPath.empty()) return false;
69+
// std::string pluginName = PythonHelper::getPluginPackageName(dirPath.string()); // Plugin name
7370

7471
// Run "pip install" if needed
7572
auto realPackageInstallDir = (std::filesystem::path(dirPath) / "site-packages").make_preferred();
@@ -78,7 +75,7 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
7875
if (!dependTmpFilePath.empty()) {
7976
int exitCode = 0;
8077
lse::getSelfPluginInstance().getLogger().info("llse.loader.python.executePipInstall.start"_tr(
81-
fmt::arg("name", ll::string_utils::u8str2str(std::filesystem::path(dirPath).filename().u8string()))
78+
fmt::arg("name", ll::string_utils::u8str2str(dirPath.filename().u8string()))
8279
));
8380

8481
if ((exitCode = PythonHelper::executePipCommand(
@@ -99,17 +96,17 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
9996
}
10097
#endif
10198
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
102-
std::filesystem::path dirPath = ll::plugin::getPluginsRoot() / manifest.name;
103-
std::string entryPath = NodeJsHelper::findEntryScript(dirPath.string());
104-
if (entryPath.empty()) return false;
105-
std::string pluginName = NodeJsHelper::getPluginPackageName(dirPath.string());
99+
std::filesystem::path dirPath = ll::plugin::getPluginsRoot() / manifest.name; // Plugin path
100+
// std::string entryPath = NodeJsHelper::findEntryScript(dirPath.string()); // Plugin entry
101+
// if (entryPath.empty()) return false;
102+
// std::string pluginName = NodeJsHelper::getPluginPackageName(dirPath.string()); // Plugin name
106103

107104
// Run "npm install" if needed
108105
if (NodeJsHelper::doesPluginPackHasDependency(dirPath.string())
109106
&& !std::filesystem::exists(std::filesystem::path(dirPath) / "node_modules")) {
110107
int exitCode = 0;
111108
lse::getSelfPluginInstance().getLogger().info("llse.loader.nodejs.executeNpmInstall.start"_tr(
112-
fmt::arg("name", ll::string_utils::u8str2str(std::filesystem::path(dirPath).filename().u8string()))
109+
fmt::arg("name", ll::string_utils::u8str2str(dirPath.filename().u8string()))
113110
));
114111
if ((exitCode = NodeJsHelper::executeNpmCommand("npm install", dirPath.string())) == 0)
115112
lse::getSelfPluginInstance().getLogger().info("llse.loader.nodejs.executeNpmInstall.success"_tr());
@@ -181,12 +178,12 @@ auto PluginManager::load(ll::plugin::Manifest manifest) -> bool {
181178
ENGINE_OWN_DATA()->pluginFileOrDirPath = entryPath.string();
182179
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
183180
if (!PythonHelper::loadPluginCode(&scriptEngine, entryPath.string(), dirPath.string())) {
184-
throw std::runtime_error(fmt::format("Failed to load plugin {0}", manifest.name));
181+
throw std::runtime_error(fmt::format("failed to load plugin code"));
185182
}
186183
#endif
187184
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
188185
if (!NodeJsHelper::loadPluginCode(&scriptEngine, entryPath.string(), dirPath.string())) {
189-
throw std::runtime_error(fmt::format("Failed to load plugin {0}", manifest.name));
186+
throw std::runtime_error(fmt::format("failed to load plugin code"));
190187
}
191188
#endif
192189
#if (defined LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS) || (defined LEGACY_SCRIPT_ENGINE_BACKEND_LUA)

0 commit comments

Comments
 (0)