Skip to content

Commit cec0658

Browse files
committed
refactor: delete unused code
1 parent 7a8d487 commit cec0658

File tree

5 files changed

+0
-69
lines changed

5 files changed

+0
-69
lines changed

src/common/util.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/**
2-
* Split a string up to the delimiter. If the delimiter doesn't exist the first
3-
* item will have all the text and the second item will be an empty string.
4-
*/
5-
export const split = (str: string, delimiter: string): [string, string] => {
6-
const index = str.indexOf(delimiter)
7-
return index !== -1 ? [str.substring(0, index).trim(), str.substring(index + 1)] : [str, ""]
8-
}
9-
101
/**
112
* Appends an 's' to the provided string if count is greater than one;
123
* otherwise the string is returned
@@ -34,27 +25,6 @@ export const normalize = (url: string, keepTrailing = false): string => {
3425
return url.replace(/\/\/+/g, "/").replace(/\/+$/, keepTrailing ? "/" : "")
3526
}
3627

37-
/**
38-
* Remove leading and trailing slashes.
39-
*/
40-
export const trimSlashes = (url: string): string => {
41-
return url.replace(/^\/+|\/+$/g, "")
42-
}
43-
44-
/**
45-
* Wrap the value in an array if it's not already an array. If the value is
46-
* undefined return an empty array.
47-
*/
48-
export const arrayify = <T>(value?: T | T[]): T[] => {
49-
if (Array.isArray(value)) {
50-
return value
51-
}
52-
if (typeof value === "undefined") {
53-
return []
54-
}
55-
return [value]
56-
}
57-
5828
// TODO: Might make sense to add Error handling to the logger itself.
5929
export function logError(logger: { error: (msg: string) => void }, prefix: string, err: unknown): void {
6030
if (err instanceof Error) {

src/node/app.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,6 @@ export const ensureAddress = (server: http.Server, protocol: string): URL | stri
102102
return addr
103103
}
104104

105-
/**
106-
* Handles error events from the server.
107-
*
108-
* If the outlying Promise didn't resolve
109-
* then we reject with the error.
110-
*
111-
* Otherwise, we log the error.
112-
*
113-
* We extracted into a function so that we could
114-
* test this logic more easily.
115-
*/
116-
export const handleServerError = (resolved: boolean, err: Error, reject: (err: Error) => void) => {
117-
// Promise didn't resolve earlier so this means it's an error
118-
// that occurs before the server can successfully listen.
119-
// Possibly triggered by listening on an invalid port or socket.
120-
if (!resolved) {
121-
reject(err)
122-
} else {
123-
// Promise resolved earlier so this is an unrelated error.
124-
util.logError(logger, "http server error", err)
125-
}
126-
}
127-
128105
/**
129106
* Handles the error that occurs in the catch block
130107
* after we try fs.unlink(args.socket).

src/node/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import type { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package"
33
import * as os from "os"
44
import * as path from "path"
55

6-
export const WORKBENCH_WEB_CONFIG_ID = "vscode-workbench-web-configuration"
7-
86
export function getPackageJson(relativePath: string): JSONSchemaForNPMPackageJsonFiles {
97
let pkg = {}
108
try {
@@ -21,7 +19,6 @@ export const vsRootPath = path.join(rootPath, "lib/vscode")
2119
const PACKAGE_JSON = "package.json"
2220
const pkg = getPackageJson(`${rootPath}/${PACKAGE_JSON}`)
2321
const codePkg = getPackageJson(`${vsRootPath}/${PACKAGE_JSON}`) || { version: "0.0.0" }
24-
export const pkgName = pkg.name || "code-server"
2522
export const version = pkg.version || "development"
2623
export const commit = pkg.commit || "development"
2724
export const codeVersion = codePkg.version || "development"

src/node/util.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,6 @@ export const enumToArray = (t: any): string[] => {
426426
return values
427427
}
428428

429-
/**
430-
* For displaying all allowed options in an enum.
431-
*/
432-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
433-
export const buildAllowedMessage = (t: any): string => {
434-
const values = enumToArray(t)
435-
return `Allowed value${values.length === 1 ? " is" : "s are"} ${values.map((t) => `'${t}'`).join(", ")}`
436-
}
437-
438429
/**
439430
* Return a promise that resolves with whether the socket path is active.
440431
*/

test/unit/node/constants.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ describe("constants", () => {
3434
jest.resetModules()
3535
})
3636

37-
it("should provide the package name", () => {
38-
expect(constants.pkgName).toBe(mockPackageJson.name)
39-
})
40-
4137
it("should provide the commit", () => {
4238
expect(constants.commit).toBe(mockPackageJson.commit)
4339
})

0 commit comments

Comments
 (0)