Archived
1
0

Format and lint

This commit is contained in:
Anmol Sethi
2020-02-14 19:46:00 -05:00
parent 80b1b1b672
commit 4aa15401c3
31 changed files with 260 additions and 141 deletions

View File

@ -68,7 +68,7 @@ export class ApiHttpProvider extends HttpProvider {
route: Route,
request: http.IncomingMessage,
socket: net.Socket,
head: Buffer
head: Buffer,
): Promise<true | undefined> {
if (!this.authenticated(request)) {
throw new Error("not authenticated")
@ -120,7 +120,7 @@ export class ApiHttpProvider extends HttpProvider {
route: Route,
request: http.IncomingMessage,
socket: net.Socket,
head: Buffer
head: Buffer,
): Promise<true> {
const sessionId = route.requestPath.replace(/^\//, "")
logger.debug("connecting session", field("sessionId", sessionId))
@ -149,8 +149,8 @@ export class ApiHttpProvider extends HttpProvider {
Buffer.from(
JSON.stringify({
protocol: "TODO",
})
)
}),
),
)
return true

View File

@ -63,7 +63,7 @@ export class MainHttpProvider extends HttpProvider {
base: this.base(route),
logLevel: logger.level,
},
(app && app.name) || ""
(app && app.name) || "",
)
}
@ -80,11 +80,11 @@ export class MainHttpProvider extends HttpProvider {
.replace(/{{APP_LIST:RUNNING}}/g, this.getAppRows(recent.running))
.replace(
/{{APP_LIST:EDITORS}}/g,
this.getAppRows(apps.filter((app) => app.categories && app.categories.includes("Editor")))
this.getAppRows(apps.filter((app) => app.categories && app.categories.includes("Editor"))),
)
.replace(
/{{APP_LIST:OTHER}}/g,
this.getAppRows(apps.filter((app) => !app.categories || !app.categories.includes("Editor")))
this.getAppRows(apps.filter((app) => !app.categories || !app.categories.includes("Editor"))),
)
return response
}

View File

@ -109,7 +109,7 @@ export class LoginHttpProvider extends HttpProvider {
remoteAddress: request.connection.remoteAddress,
userAgent: request.headers["user-agent"],
timestamp: Math.floor(new Date().getTime() / 1000),
})
}),
)
throw new Error("Incorrect password")

View File

@ -102,7 +102,7 @@ export class VscodeHttpProvider extends HttpProvider {
"Upgrade: websocket",
"Connection: Upgrade",
`Sec-WebSocket-Accept: ${reply}`,
].join("\r\n") + "\r\n\r\n"
].join("\r\n") + "\r\n\r\n",
)
const vscode = await this._vscode
@ -146,7 +146,7 @@ export class VscodeHttpProvider extends HttpProvider {
const response = await this.getUtf8Resource(this.vsRootPath, route.requestPath)
response.content = response.content.replace(
/{{COMMIT}}/g,
this.workbenchOptions ? this.workbenchOptions.commit : ""
this.workbenchOptions ? this.workbenchOptions.commit : "",
)
response.cache = true
return response
@ -186,7 +186,7 @@ export class VscodeHttpProvider extends HttpProvider {
settings.lastVisited,
this.args._ && this.args._.length > 0 ? { url: this.args._[0] } : undefined,
],
remoteAuthority
remoteAuthority,
)
const [response, options] = await Promise.all([
await this.getUtf8Resource(this.rootPath, "src/browser/pages/vscode.html"),
@ -229,7 +229,7 @@ export class VscodeHttpProvider extends HttpProvider {
*/
private async getFirstValidPath(
startPaths: Array<{ url?: string | string[]; workspace?: boolean } | undefined>,
remoteAuthority: string
remoteAuthority: string,
): Promise<StartPath | undefined> {
for (let i = 0; i < startPaths.length; ++i) {
const startPath = startPaths[i]

View File

@ -92,13 +92,13 @@ export const optionDescriptions = (): string[] => {
long: k.length > prev.long ? k.length : prev.long,
short: v.short && v.short.length > prev.short ? v.short.length : prev.short,
}),
{ short: 0, long: 0 }
{ short: 0, long: 0 },
)
return entries.map(
([k, v]) =>
`${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k}${" ".repeat(
widths.long - k.length
)} ${v.description}${typeof v.type === "object" ? ` [${Object.values(v.type).join(", ")}]` : ""}`
widths.long - k.length,
)} ${v.description}${typeof v.type === "object" ? ` [${Object.values(v.type).join(", ")}]` : ""}`,
)
}

View File

@ -66,7 +66,7 @@ const main = async (args: Args): Promise<void> => {
logger.info(
typeof args.cert === "string"
? ` - Using provided certificate${args["cert-key"] ? " and key" : ""} for HTTPS`
: ` - Using generated certificate and key for HTTPS`
: ` - Using generated certificate and key for HTTPS`,
)
} else {
logger.info(" - Not serving HTTPS")

View File

@ -142,7 +142,7 @@ export abstract class HttpProvider {
route: Route,
request: http.IncomingMessage,
socket: net.Socket,
head: Buffer
head: Buffer,
): Promise<true | undefined>
/**
@ -380,7 +380,7 @@ export class HttpServer {
cert: this.options.cert && fs.readFileSync(this.options.cert),
key: this.options.certKey && fs.readFileSync(this.options.certKey),
},
this.onRequest
this.onRequest,
)
} else {
this.server = http.createServer(this.onRequest)
@ -420,7 +420,7 @@ export class HttpServer {
commit: this.options.commit,
password: this.options.password,
},
a1
a1,
)
this.providers.set(`/${endpoint}`, p)
return p

View File

@ -14,7 +14,7 @@ const getXdgDataDir = (): string => {
case "darwin":
return path.join(
process.env.XDG_DATA_HOME || path.join(os.homedir(), "Library/Application Support"),
"code-server"
"code-server",
)
default:
return path.join(process.env.XDG_DATA_HOME || path.join(os.homedir(), ".local/share"), "code-server")

View File

@ -76,7 +76,7 @@ export class IpcMain {
`${child ? "wrapper" : "inner process"} ${process.pid} received message from ${
child ? child.pid : this.parentPid
}`,
field("message", message)
field("message", message),
)
if (message.type === "handshake") {
target.removeListener("message", onMessage)
@ -122,7 +122,7 @@ export const ipcMain = (): IpcMain => {
_ipcMain = new IpcMain(
typeof process.env.CODE_SERVER_PARENT_PID !== "undefined"
? parseInt(process.env.CODE_SERVER_PARENT_PID)
: undefined
: undefined,
)
}
return _ipcMain