2021-05-05 19:20:38 +02:00
|
|
|
import { parse, parseConfigFile, setDefaults } from "../../src/node/cli"
|
|
|
|
import { runCodeServer } from "../../src/node/main"
|
2021-03-10 00:36:56 +01:00
|
|
|
import * as httpserver from "./httpserver"
|
|
|
|
|
2021-05-05 19:20:38 +02:00
|
|
|
export async function setup(argv: string[], configFile?: string): Promise<httpserver.HttpServer> {
|
2021-05-06 00:58:04 +02:00
|
|
|
argv = ["--bind-addr=localhost:0", "--log=warn", ...argv]
|
2021-03-10 00:36:56 +01:00
|
|
|
|
|
|
|
const cliArgs = parse(argv)
|
|
|
|
const configArgs = parseConfigFile(configFile || "", "test/integration.ts")
|
|
|
|
const args = await setDefaults(cliArgs, configArgs)
|
|
|
|
|
2021-05-05 19:20:38 +02:00
|
|
|
const server = await runCodeServer(args)
|
2021-03-10 00:36:56 +01:00
|
|
|
|
2021-05-05 19:20:38 +02:00
|
|
|
return new httpserver.HttpServer(server)
|
2021-03-10 00:36:56 +01:00
|
|
|
}
|