plugin.ts: Describe private counterpart functions
Addresses Will's comments.
This commit is contained in:
parent
e03bbe3149
commit
139a28e0ea
@ -110,6 +110,13 @@ export class PluginAPI {
|
|||||||
await this._loadPlugins(path.join(__dirname, "../../plugins"))
|
await this._loadPlugins(path.join(__dirname, "../../plugins"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _loadPlugins is the counterpart to loadPlugins.
|
||||||
|
*
|
||||||
|
* It differs in that it loads all plugins in a single
|
||||||
|
* directory whereas loadPlugins uses all available directories
|
||||||
|
* as documented.
|
||||||
|
*/
|
||||||
private async _loadPlugins(dir: string): Promise<void> {
|
private async _loadPlugins(dir: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const entries = await fsp.readdir(dir, { withFileTypes: true })
|
const entries = await fsp.readdir(dir, { withFileTypes: true })
|
||||||
@ -149,6 +156,11 @@ export class PluginAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _loadPlugin is the counterpart to loadPlugin and actually
|
||||||
|
* loads the plugin now that we know there is no duplicate
|
||||||
|
* and that the package.json has been read.
|
||||||
|
*/
|
||||||
private _loadPlugin(dir: string, packageJSON: PackageJSON): Plugin {
|
private _loadPlugin(dir: string, packageJSON: PackageJSON): Plugin {
|
||||||
dir = path.resolve(dir)
|
dir = path.resolve(dir)
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import * as express from "express"
|
import * as express from "express"
|
||||||
import { PluginAPI } from "../plugin"
|
import { PluginAPI } from "../plugin"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the /api/applications endpoint
|
||||||
|
*/
|
||||||
export function router(papi: PluginAPI): express.Router {
|
export function router(papi: PluginAPI): express.Router {
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ describe("plugin", () => {
|
|||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "test app",
|
name: "Test App",
|
||||||
version: "4.0.0",
|
version: "4.0.0",
|
||||||
|
|
||||||
description: "my description",
|
description: "This app does XYZ.",
|
||||||
iconPath: "/icon.svg",
|
iconPath: "/icon.svg",
|
||||||
|
|
||||||
plugin: {
|
plugin: {
|
||||||
@ -28,8 +28,8 @@ describe("plugin", () => {
|
|||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
modulePath: path.join(__dirname, "test-plugin"),
|
modulePath: path.join(__dirname, "test-plugin"),
|
||||||
|
|
||||||
description: "Plugin used in code-server tests.",
|
|
||||||
displayName: "Test Plugin",
|
displayName: "Test Plugin",
|
||||||
|
description: "Plugin used in code-server tests.",
|
||||||
path: "/test-plugin",
|
path: "/test-plugin",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -21,11 +21,11 @@ export function router(): express.Router {
|
|||||||
export function applications(): pluginapi.Application[] {
|
export function applications(): pluginapi.Application[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: "test app",
|
name: "Test App",
|
||||||
version: "4.0.0",
|
version: "4.0.0",
|
||||||
iconPath: "/icon.svg",
|
iconPath: "/icon.svg",
|
||||||
|
|
||||||
description: "my description",
|
description: "This app does XYZ.",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user