Skip to content

Commit 608adb6

Browse files
committed
fix CI
1 parent 0440615 commit 608adb6

File tree

4 files changed

+48
-45
lines changed

4 files changed

+48
-45
lines changed

src/node/plugin.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as path from "path"
2-
import * as util from "./util"
3-
import * as pluginapi from "../../typings/plugin"
1+
import { Logger, field } from "@coder/logger"
2+
import * as express from "express"
43
import * as fs from "fs"
4+
import * as path from "path"
55
import * as semver from "semver"
6+
import * as pluginapi from "../../typings/plugin"
67
import { version } from "./constants"
8+
import * as util from "./util"
79
const fsp = fs.promises
8-
import { Logger, field } from "@coder/logger"
9-
import * as express from "express"
1010

1111
// These fields are populated from the plugin's package.json.
1212
interface Plugin extends pluginapi.Plugin {
@@ -34,7 +34,7 @@ export class PluginAPI {
3434
*/
3535
private readonly csPlugin = "",
3636
private readonly csPluginPath = `${path.join(util.paths.data, "plugins")}:/usr/share/code-server/plugins`,
37-
){
37+
) {
3838
this.logger = logger.named("pluginapi")
3939
}
4040

@@ -44,7 +44,7 @@ export class PluginAPI {
4444
*/
4545
public async applications(): Promise<Application[]> {
4646
const apps = new Array<Application>()
47-
for (let p of this.plugins) {
47+
for (const p of this.plugins) {
4848
const pluginApps = await p.applications()
4949

5050
// TODO prevent duplicates
@@ -62,7 +62,7 @@ export class PluginAPI {
6262
* mount mounts all plugin routers onto r.
6363
*/
6464
public mount(r: express.Router): void {
65-
for (let p of this.plugins) {
65+
for (const p of this.plugins) {
6666
r.use(`/${p.name}`, p.router())
6767
}
6868
}
@@ -75,14 +75,14 @@ export class PluginAPI {
7575
// Built-in plugins.
7676
await this._loadPlugins(path.join(__dirname, "../../plugins"))
7777

78-
for (let dir of this.csPluginPath.split(":")) {
78+
for (const dir of this.csPluginPath.split(":")) {
7979
if (!dir) {
8080
continue
8181
}
8282
await this._loadPlugins(dir)
8383
}
8484

85-
for (let dir of this.csPlugin.split(":")) {
85+
for (const dir of this.csPlugin.split(":")) {
8686
if (!dir) {
8787
continue
8888
}
@@ -93,7 +93,7 @@ export class PluginAPI {
9393
private async _loadPlugins(dir: string): Promise<void> {
9494
try {
9595
const entries = await fsp.readdir(dir, { withFileTypes: true })
96-
for (let ent of entries) {
96+
for (const ent of entries) {
9797
if (!ent.isDirectory()) {
9898
continue
9999
}
@@ -124,14 +124,12 @@ export class PluginAPI {
124124

125125
private _loadPlugin(dir: string, packageJSON: PackageJSON): Plugin {
126126
const logger = this.logger.named(packageJSON.name)
127-
logger.debug("loading plugin",
128-
field("plugin_dir", dir),
129-
field("package_json", packageJSON),
130-
)
127+
logger.debug("loading plugin", field("plugin_dir", dir), field("package_json", packageJSON))
131128

132129
if (!semver.satisfies(version, packageJSON.engines["code-server"])) {
133-
throw new Error(`plugin range ${q(packageJSON.engines["code-server"])} incompatible` +
134-
` with code-server version ${version}`)
130+
throw new Error(
131+
`plugin range ${q(packageJSON.engines["code-server"])} incompatible` + ` with code-server version ${version}`,
132+
)
135133
}
136134
if (!packageJSON.name) {
137135
throw new Error("plugin missing name")

test/plugin.test.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { describe } from "mocha"
2-
import { PluginAPI } from "../src/node/plugin"
31
import { logger } from "@coder/logger"
4-
import * as path from "path"
52
import * as assert from "assert"
3+
import { describe } from "mocha"
4+
import * as path from "path"
5+
import { PluginAPI } from "../src/node/plugin"
66

77
/**
88
* Use $LOG_LEVEL=debug to see debug logs.
@@ -15,17 +15,20 @@ describe("plugin", () => {
1515
// We remove the function fields from the application's plugins.
1616
const apps = JSON.parse(JSON.stringify(await papi.applications()))
1717

18-
assert.deepEqual([
19-
{
20-
name: "goland",
21-
version: "4.0.0",
22-
iconPath: "icon.svg",
23-
plugin: {
24-
name: "test-plugin",
25-
version: "1.0.0",
26-
description: "Fake plugin for testing code-server's plugin API",
18+
assert.deepEqual(
19+
[
20+
{
21+
name: "goland",
22+
version: "4.0.0",
23+
iconPath: "icon.svg",
24+
plugin: {
25+
name: "test-plugin",
26+
version: "1.0.0",
27+
description: "Fake plugin for testing code-server's plugin API",
28+
},
2729
},
28-
},
29-
], apps)
30+
],
31+
apps,
32+
)
3033
})
3134
})

test/test-plugin/src/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as pluginapi from "../../../typings/plugin"
21
import * as express from "express"
3-
import * as path from "path";
2+
import * as path from "path"
3+
import * as pluginapi from "../../../typings/plugin"
44

55
export function init(config: pluginapi.PluginConfig) {
66
config.logger.debug("test-plugin loaded!")
@@ -15,9 +15,11 @@ export function router(): express.Router {
1515
}
1616

1717
export function applications(): pluginapi.Application[] {
18-
return [{
19-
name: "goland",
20-
version: "4.0.0",
21-
iconPath: "icon.svg",
22-
}]
18+
return [
19+
{
20+
name: "goland",
21+
version: "4.0.0",
22+
iconPath: "icon.svg",
23+
},
24+
]
2325
}

test/test-plugin/tsconfig.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
/* Basic Options */
66
// "incremental": true, /* Enable incremental compilation */
7-
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8-
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
7+
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
8+
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
99
// "lib": [], /* Specify library files to be included in the compilation. */
1010
// "allowJs": true, /* Allow javascript files to be compiled. */
1111
// "checkJs": true, /* Report errors in .js files. */
@@ -14,7 +14,7 @@
1414
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
1515
// "sourceMap": true, /* Generates corresponding '.map' file. */
1616
// "outFile": "./", /* Concatenate and emit output to single file. */
17-
"outDir": "./out", /* Redirect output structure to the directory. */
17+
"outDir": "./out" /* Redirect output structure to the directory. */,
1818
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
1919
// "composite": true, /* Enable project compilation */
2020
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
@@ -25,7 +25,7 @@
2525
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
2626

2727
/* Strict Type-Checking Options */
28-
"strict": true, /* Enable all strict type-checking options. */
28+
"strict": true /* Enable all strict type-checking options. */,
2929
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
3030
// "strictNullChecks": true, /* Enable strict null checks. */
3131
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
@@ -48,7 +48,7 @@
4848
// "typeRoots": [], /* List of folders to include type definitions from. */
4949
// "types": [], /* Type declaration files to be included in compilation. */
5050
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
51-
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
51+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
5252
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
5353
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
5454

@@ -63,7 +63,7 @@
6363
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
6464

6565
/* Advanced Options */
66-
"skipLibCheck": true, /* Skip type checking of declaration files. */
67-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
66+
"skipLibCheck": true /* Skip type checking of declaration files. */,
67+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
6868
}
6969
}

0 commit comments

Comments
 (0)