mirror of https://git.tuxpa.in/a/code-server.git
plugin: Make init and applications callbacks optional
This commit is contained in:
parent
9d39c53c99
commit
277211c4ce
|
@ -55,6 +55,9 @@ export class PluginAPI {
|
||||||
public async applications(): Promise<Application[]> {
|
public async applications(): Promise<Application[]> {
|
||||||
const apps = new Array<Application>()
|
const apps = new Array<Application>()
|
||||||
for (const [, p] of this.plugins) {
|
for (const [, p] of this.plugins) {
|
||||||
|
if (!p.applications) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
const pluginApps = await p.applications()
|
const pluginApps = await p.applications()
|
||||||
|
|
||||||
// Add plugin key to each app.
|
// Add plugin key to each app.
|
||||||
|
@ -86,6 +89,9 @@ export class PluginAPI {
|
||||||
*/
|
*/
|
||||||
public mount(r: express.Router): void {
|
public mount(r: express.Router): void {
|
||||||
for (const [, p] of this.plugins) {
|
for (const [, p] of this.plugins) {
|
||||||
|
if (!p.router) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
r.use(`${p.routerPath}`, p.router())
|
r.use(`${p.routerPath}`, p.router())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,8 +129,10 @@ export interface Plugin {
|
||||||
* Returns the plugin's router.
|
* Returns the plugin's router.
|
||||||
*
|
*
|
||||||
* Mounted at <code-sever-root>/<plugin-path>
|
* Mounted at <code-sever-root>/<plugin-path>
|
||||||
|
*
|
||||||
|
* If not present, the plugin provides no routes.
|
||||||
*/
|
*/
|
||||||
router(): express.Router
|
router?(): express.Router
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* code-server uses this to collect the list of applications that
|
* code-server uses this to collect the list of applications that
|
||||||
|
@ -139,8 +141,10 @@ export interface Plugin {
|
||||||
* refresh the list of applications
|
* refresh the list of applications
|
||||||
*
|
*
|
||||||
* Ensure this is as fast as possible.
|
* Ensure this is as fast as possible.
|
||||||
|
*
|
||||||
|
* If not present, the plugin provides no applications.
|
||||||
*/
|
*/
|
||||||
applications(): Application[] | Promise<Application[]>
|
applications?(): Application[] | Promise<Application[]>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue