File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -108,9 +108,19 @@ export class PicGo extends EventEmitter implements IPicGo {
108
108
}
109
109
}
110
110
111
- use ( plugin : IPicGoPlugin ) : IPicGoPluginInterface {
112
- const pluginInstance = plugin ( this )
113
- return pluginInstance
111
+ /**
112
+ * easily mannually load a plugin
113
+ * if provide plugin name, will register plugin by name
114
+ * or just instantiate a plugin
115
+ */
116
+ use ( plugin : IPicGoPlugin , name ?: string ) : IPicGoPluginInterface {
117
+ if ( name ) {
118
+ this . pluginLoader . registerPlugin ( name , plugin )
119
+ return this . pluginLoader . getPlugin ( name ) !
120
+ } else {
121
+ const pluginInstance = plugin ( this )
122
+ return pluginInstance
123
+ }
114
124
}
115
125
116
126
registerCommands ( ) : void {
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ export class PluginLoader implements IPluginLoader {
90
90
setCurrentPluginName ( name )
91
91
const pluginInterface = plugin ( this . ctx )
92
92
this . pluginMap . set ( name , pluginInterface )
93
- plugin ( this . ctx ) . register ( this . ctx )
93
+ pluginInterface . register ( this . ctx )
94
94
}
95
95
} catch ( e ) {
96
96
this . pluginMap . delete ( name )
You can’t perform that action at this time.
0 commit comments