@@ -61,18 +61,18 @@ export const loadPluginFromFile = async <T>(
61
61
/**
62
62
* Load plugin from file or directory.
63
63
*
64
- * const plugin = await loadPlugin(process.cwd(), null, './renderer.js');
65
- * const plugin = await loadPlugin('../node_modules', 'doxdox-renderer-', 'json');
64
+ * const plugin = await loadPlugin([ process.cwd()] , null, './renderer.js');
65
+ * const plugin = await loadPlugin([ '../node_modules'] , 'doxdox-renderer-', 'json');
66
66
*
67
- * @param {string } [directory ] Root directory to load plugin from.
67
+ * @param {string[] } [directories ] Root directories to load plugin from.
68
68
* @param {string } [prefix] Optional prefix to attach to the pathOrPackage.
69
69
* @param {string } [pathOrPackage] Path or package name.
70
70
* @return {Promise<T | null> } Plugin default method.
71
71
* @public
72
72
*/
73
73
74
74
export const loadPlugin = async < T > (
75
- directory : string ,
75
+ directories : string [ ] ,
76
76
prefix : string | null ,
77
77
pathOrPackage : string
78
78
) : Promise < T | null > => {
@@ -83,20 +83,17 @@ export const loadPlugin = async <T>(
83
83
return await loadPluginFromFile ( pathOrPackage ) ;
84
84
} else if ( await isDirectory ( pathOrPackage ) ) {
85
85
return await loadPluginFromPackagePath ( pathOrPackage ) ;
86
- } else if (
87
- await isDirectory (
88
- join (
89
- directory ,
86
+ } else {
87
+ for ( let i = 0 ; i < directories ?. length ; i += 1 ) {
88
+ const path = join (
89
+ directories [ i ] ,
90
90
`${ prefix } ${ pathOrPackage . replace ( prefixPattern , '' ) } `
91
- )
92
- )
93
- ) {
94
- return await loadPluginFromPackagePath (
95
- join (
96
- directory ,
97
- `${ prefix } ${ pathOrPackage . replace ( prefixPattern , '' ) } `
98
- )
99
- ) ;
91
+ ) ;
92
+
93
+ if ( await isDirectory ( path ) ) {
94
+ return await loadPluginFromPackagePath ( path ) ;
95
+ }
96
+ }
100
97
}
101
98
} catch ( err ) {
102
99
if ( process . env . DEBUG ) {
0 commit comments