Skip to content

Commit 277211c

Browse files
committed
plugin: Make init and applications callbacks optional
1 parent 9d39c53 commit 277211c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/node/plugin.ts

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export class PluginAPI {
5555
public async applications(): Promise<Application[]> {
5656
const apps = new Array<Application>()
5757
for (const [, p] of this.plugins) {
58+
if (!p.applications) {
59+
continue
60+
}
5861
const pluginApps = await p.applications()
5962

6063
// Add plugin key to each app.
@@ -86,6 +89,9 @@ export class PluginAPI {
8689
*/
8790
public mount(r: express.Router): void {
8891
for (const [, p] of this.plugins) {
92+
if (!p.router) {
93+
continue
94+
}
8995
r.use(`${p.routerPath}`, p.router())
9096
}
9197
}

typings/pluginapi.d.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ export interface Plugin {
129129
* Returns the plugin's router.
130130
*
131131
* Mounted at <code-sever-root>/<plugin-path>
132+
*
133+
* If not present, the plugin provides no routes.
132134
*/
133-
router(): express.Router
135+
router?(): express.Router
134136

135137
/**
136138
* code-server uses this to collect the list of applications that
@@ -139,8 +141,10 @@ export interface Plugin {
139141
* refresh the list of applications
140142
*
141143
* Ensure this is as fast as possible.
144+
*
145+
* If not present, the plugin provides no applications.
142146
*/
143-
applications(): Application[] | Promise<Application[]>
147+
applications?(): Application[] | Promise<Application[]>
144148
}
145149

146150
/**

0 commit comments

Comments
 (0)