Archived
1
0

Formatting and linting fixes

This commit is contained in:
Anmol Sethi 2021-01-14 10:55:19 -05:00
parent 60233d0974
commit 5c06646f58
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB
4 changed files with 18 additions and 15 deletions

View File

@ -529,8 +529,8 @@ export async function readConfigFile(configPath?: string): Promise<ConfigArgs> {
* configPath is used as the filename in error messages
*/
export function parseConfigFile(configFile: string, configPath: string): ConfigArgs {
if (configFile == "") {
return { _: [], config: configPath }
if (!configFile) {
return { _: [], config: configPath }
}
const config = yaml.safeLoad(configFile, {

View File

@ -64,7 +64,7 @@ export class HttpServer {
public port(): number {
const addr = this.hs.address()
if (addr && typeof addr == "object") {
if (addr && typeof addr === "object") {
return addr.port
}
throw new Error("server not listening or listening on unix socket")

View File

@ -1,12 +1,15 @@
import { createApp } from "../src/node/app"
import { register } from "../src/node/routes"
import { parse, setDefaults, parseConfigFile, DefaultedArgs } from "../src/node/cli"
import * as httpserver from "./httpserver"
import * as express from "express"
import { createApp } from "../src/node/app"
import { parse, setDefaults, parseConfigFile, DefaultedArgs } from "../src/node/cli"
import { register } from "../src/node/routes"
import * as httpserver from "./httpserver"
export async function setup(argv: string[], configFile?: string): Promise<[express.Application, express.Application, httpserver.HttpServer, DefaultedArgs]> {
export async function setup(
argv: string[],
configFile?: string,
): Promise<[express.Application, express.Application, httpserver.HttpServer, DefaultedArgs]> {
const cliArgs = parse(argv)
let configArgs = parseConfigFile(configFile || "", "test/integration.ts")
const configArgs = parseConfigFile(configFile || "", "test/integration.ts")
const args = await setDefaults(cliArgs, configArgs)
const [app, wsApp, server] = await createApp(args)

View File

@ -1,11 +1,11 @@
import * as integration from "./integration"
import * as httpserver from "./httpserver"
import * as express from "express"
import * as assert from "assert"
import * as express from "express"
import * as httpserver from "./httpserver"
import * as integration from "./integration"
describe("proxy", () => {
let codeServer: httpserver.HttpServer | undefined
let nhooyrDevServer = new httpserver.HttpServer()
const nhooyrDevServer = new httpserver.HttpServer()
let proxyPath: string
before(async () => {
@ -32,14 +32,14 @@ describe("proxy", () => {
})
it("should rewrite the base path", async () => {
;[,, codeServer,] = await integration.setup(["--auth=none"], "")
;[, , codeServer] = await integration.setup(["--auth=none"], "")
const resp = await codeServer.fetch(proxyPath)
assert.equal(resp.status, 200)
assert.equal(await resp.json(), "asher is the best")
})
it("should not rewrite the base path", async () => {
;[,,codeServer,] = await integration.setup(["--auth=none", "--proxy-path-passthrough=true"], "")
;[, , codeServer] = await integration.setup(["--auth=none", "--proxy-path-passthrough=true"], "")
const resp = await codeServer.fetch(proxyPath)
assert.equal(resp.status, 200)
assert.equal(await resp.json(), "joe is the best")