Skip to content

Commit 8d3a772

Browse files
committed
plugin.d.ts: Document plugin priority correctly
1 parent 75e52a3 commit 8d3a772

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/node/plugin.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,22 @@ export class PluginAPI {
8989
* this.csPluginPath and the built in plugins.
9090
*/
9191
public async loadPlugins(): Promise<void> {
92-
// Built-in plugins.
93-
await this._loadPlugins(path.join(__dirname, "../../plugins"))
94-
95-
for (const dir of this.csPluginPath.split(":")) {
92+
for (const dir of this.csPlugin.split(":")) {
9693
if (!dir) {
9794
continue
9895
}
99-
await this._loadPlugins(dir)
96+
await this.loadPlugin(dir)
10097
}
10198

102-
for (const dir of this.csPlugin.split(":")) {
99+
for (const dir of this.csPluginPath.split(":")) {
103100
if (!dir) {
104101
continue
105102
}
106-
await this.loadPlugin(dir)
103+
await this._loadPlugins(dir)
107104
}
105+
106+
// Built-in plugins.
107+
await this._loadPlugins(path.join(__dirname, "../../plugins"))
108108
}
109109

110110
private async _loadPlugins(dir: string): Promise<void> {

typings/plugin.d.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ import * as express from "express"
1818
*
1919
* Plugins are just node modules.
2020
*
21-
* code-server uses $CS_PLUGIN_PATH to find plugins. Each subdirectory in
21+
* 1. code-server uses $CS_PLUGIN to find plugins.
22+
*
23+
* e.g. CS_PLUGIN=/tmp/will:/tmp/teffen will cause code-server to load
24+
* /tmp/will and /tmp/teffen as plugins.
25+
*
26+
* 2. code-server uses $CS_PLUGIN_PATH to find plugins. Each subdirectory in
2227
* $CS_PLUGIN_PATH with a package.json where the engine is code-server is
2328
* a valid plugin.
2429
*
@@ -29,16 +34,14 @@ import * as express from "express"
2934
* ~/.local/share/code-server/plugins:/usr/share/code-server/plugins
3035
* if unset.
3136
*
32-
* code-server also uses $CS_PLUGIN to find plugins.
3337
*
34-
* e.g. CS_PLUGIN=/tmp/will:/tmp/teffen will cause code-server to load
35-
* /tmp/will and /tmp/teffen as plugins.
38+
* 3. Built in plugins are loaded from __dirname/../plugins
3639
*
37-
* Built in plugins are also loaded from __dirname/../plugins
40+
* Plugins are required as soon as they are found and then initialized.
41+
* See the Plugin interface for details.
3842
*
39-
* Priority is $CS_PLUGIN, $CS_PLUGIN_PATH and then the builtin plugins.
40-
* After the search is complete, plugins will be required in first found order and
41-
* initialized. See the Plugin interface for details.
43+
* If two plugins are found with the exact same name, then code-server will
44+
* use the first one and emit a warning.
4245
*
4346
* There is also a /api/applications endpoint to allow programmatic access to all
4447
* available applications. It could be used to create a custom application dashboard
@@ -51,9 +54,6 @@ import * as express from "express"
5154
* The plugin's name, description and version are fetched from its module's package.json
5255
*
5356
* The plugin's router will be mounted at <code-sever-root>/<plugin-name>
54-
*
55-
* If two plugins are found with the exact same name, then code-server will
56-
* use the last one and emit a warning.
5757
*/
5858
export interface Plugin {
5959
/**

0 commit comments

Comments
 (0)