Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

chore: When there is no plugin, there is no need to reset the index.ts file

robin5ab7d9b3a035
diff --git a/ui/scripts/plugin.js b/ui/scripts/plugin.js
index d26dbcdc..cdd84d17 100644
--- a/ui/scripts/plugin.js
+++ b/ui/scripts/plugin.js
@@ -71,13 +71,22 @@ function addPluginToIndexTs(packageName) {
fs.writeFileSync(indexTsPath, lines.join('\n'));
}
+const pluginLength = pluginFolders.filter((folder) => {
+ const pluginFolder = path.join(pluginPath, folder);
+ const stat = fs.statSync(pluginFolder);
+ return stat.isDirectory() && folder !== 'builtin';
+}).length
+
+if (pluginLength > 0) {
+ resetIndexTs();
+}
resetPackageJson();
-resetIndexTs();
+
pluginFolders.forEach((folder) => {
const pluginFolder = path.join(pluginPath, folder);
const stat = fs.statSync(pluginFolder);
-
+
if (stat.isDirectory() && folder !== 'builtin') {
if (!fs.existsSync(path.join(pluginFolder, 'index.ts'))) {
return;
@@ -85,7 +94,7 @@ pluginFolders.forEach((folder) => {
const packageJson = require(path.join(pluginFolder, 'package.json'));
const packageName = packageJson.name;
-
+
addPluginToPackageJson(packageName);
addPluginToIndexTs(packageName);
}