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