Yuki Takei 9 ani în urmă
părinte
comite
beccf0c2d7
1 a modificat fișierele cu 3 adăugiri și 17 ștergeri
  1. 3 17
      lib/plugins/plugin-utils.js

+ 3 - 17
lib/plugins/plugin-utils.js

@@ -68,28 +68,14 @@ class PluginUtils {
 
   /**
    * list plugin module names that starts with 'crowi-plugin-'
-   * borrowing from: https://github.com/hexojs/hexo/blob/d1db459c92a4765620343b95789361cbbc6414c5/lib/hexo/load_plugins.js#L17
    *
-   * @returns
+   * @returns array of plugin names
    *
    * @memberOf PluginService
    */
   listPluginNames(rootDir) {
-    var packagePath = path.join(rootDir, 'package.json');
-
-    // Make sure package.json exists
-    if (!fs.existsSync(packagePath)) {
-      return [];
-    }
-
-    // Read package.json and find dependencies
-    const content = fs.readFileSync(packagePath);
-    const json = JSON.parse(content);
-    const deps = json.dependencies || {};
-    return Object.keys(deps).filter((name) => {
-      // Ignore plugins whose name is not started with "crowi-"
-      return /^crowi-plugin-/.test(name);
-    });
+    const plugins = this.listPlugins(rootDir);
+    return Object.keys(plugins);
   }
 }