diff --git a/src/node/plugin.ts b/src/node/plugin.ts index f0dca2754..a34c2027f 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -89,8 +89,12 @@ export class PluginAPI { * this.csPluginPath and the built in plugins. */ public async loadPlugins(): Promise { - // Built-in plugins. - await this._loadPlugins(path.join(__dirname, "../../plugins")) + for (const dir of this.csPlugin.split(":")) { + if (!dir) { + continue + } + await this.loadPlugin(dir) + } for (const dir of this.csPluginPath.split(":")) { if (!dir) { @@ -99,12 +103,8 @@ export class PluginAPI { await this._loadPlugins(dir) } - for (const dir of this.csPlugin.split(":")) { - if (!dir) { - continue - } - await this.loadPlugin(dir) - } + // Built-in plugins. + await this._loadPlugins(path.join(__dirname, "../../plugins")) } private async _loadPlugins(dir: string): Promise { diff --git a/typings/plugin.d.ts b/typings/plugin.d.ts index 92c3acada..549c15f11 100644 --- a/typings/plugin.d.ts +++ b/typings/plugin.d.ts @@ -18,7 +18,12 @@ import * as express from "express" * * Plugins are just node modules. * - * code-server uses $CS_PLUGIN_PATH to find plugins. Each subdirectory in + * 1. code-server uses $CS_PLUGIN to find plugins. + * + * e.g. CS_PLUGIN=/tmp/will:/tmp/teffen will cause code-server to load + * /tmp/will and /tmp/teffen as plugins. + * + * 2. code-server uses $CS_PLUGIN_PATH to find plugins. Each subdirectory in * $CS_PLUGIN_PATH with a package.json where the engine is code-server is * a valid plugin. * @@ -29,16 +34,14 @@ import * as express from "express" * ~/.local/share/code-server/plugins:/usr/share/code-server/plugins * if unset. * - * code-server also uses $CS_PLUGIN to find plugins. * - * e.g. CS_PLUGIN=/tmp/will:/tmp/teffen will cause code-server to load - * /tmp/will and /tmp/teffen as plugins. + * 3. Built in plugins are loaded from __dirname/../plugins * - * Built in plugins are also loaded from __dirname/../plugins + * Plugins are required as soon as they are found and then initialized. + * See the Plugin interface for details. * - * Priority is $CS_PLUGIN, $CS_PLUGIN_PATH and then the builtin plugins. - * After the search is complete, plugins will be required in first found order and - * initialized. See the Plugin interface for details. + * If two plugins are found with the exact same name, then code-server will + * use the first one and emit a warning. * * There is also a /api/applications endpoint to allow programmatic access to all * available applications. It could be used to create a custom application dashboard @@ -51,9 +54,6 @@ import * as express from "express" * The plugin's name, description and version are fetched from its module's package.json * * The plugin's router will be mounted at / - * - * If two plugins are found with the exact same name, then code-server will - * use the last one and emit a warning. */ export interface Plugin { /**