From 0aa98279d679c97ded60e71a94267b4d2284f0cd Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 9 Sep 2020 00:06:28 -0400 Subject: [PATCH] Fixes for CI --- src/node/cli.ts | 40 +++++++++++++++++++++++----------------- src/node/coder-cloud.ts | 16 ++++++++-------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/node/cli.ts b/src/node/cli.ts index 318b85935..c4d0d9dd4 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -48,7 +48,7 @@ export interface Args extends VsArgs { readonly "reuse-window"?: boolean readonly "new-window"?: boolean - readonly "expose"?: OptionalString + readonly expose?: OptionalString } interface Option { @@ -131,8 +131,9 @@ const options: Options> = { force: { type: "boolean", description: "Avoid prompts when installing VS Code extensions." }, "install-extension": { type: "string[]", - description: "Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`.\n" + - "To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.", + description: + "Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`.\n" + + "To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.", }, "enable-proposed-api": { type: "string[]", @@ -158,13 +159,13 @@ const options: Options> = { log: { type: LogLevel }, verbose: { type: "boolean", short: "vvv", description: "Enable verbose logging." }, - "expose": { + expose: { type: OptionalString, description: ` Securely expose code-server via Coder Cloud with the passed name. You'll get a URL like https://myname.coder-cloud.com at which you can easily access your code-server instance. Authorization is done via GitHub. Only the first code-server spawned with the current - configuration will be accessible.` + configuration will be accessible.`, }, } @@ -177,18 +178,23 @@ export const optionDescriptions = (): string[] => { }), { short: 0, long: 0 }, ) - return entries.map( - ([k, v]) => { - let help = `${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k} ` - return help + v.description?.trim().split(/\n/).map((line, i) => { - line = line.trim() - if (i == 0) { - return " ".repeat(widths.long - k.length) + line - } - return " ".repeat(widths.long + widths.short + 6) + line - }).join("\n") - }, - ) + return entries.map(([k, v]) => { + const help = `${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k} ` + return ( + help + + v.description + ?.trim() + .split(/\n/) + .map((line, i) => { + line = line.trim() + if (i === 0) { + return " ".repeat(widths.long - k.length) + line + } + return " ".repeat(widths.long + widths.short + 6) + line + }) + .join("\n") + ) + }) } export const parse = ( diff --git a/src/node/coder-cloud.ts b/src/node/coder-cloud.ts index 167b80c3f..b621b08cd 100644 --- a/src/node/coder-cloud.ts +++ b/src/node/coder-cloud.ts @@ -1,9 +1,9 @@ -import { spawn } from "child_process" -import path from "path" import { logger } from "@coder/logger" -import split2 from "split2" +import { spawn } from "child_process" import delay from "delay" import fs from "fs" +import path from "path" +import split2 from "split2" import { promisify } from "util" import xdgBasedir from "xdg-basedir" @@ -14,7 +14,7 @@ export async function coderCloudExpose(serverName: string): Promise { stdio: ["inherit", "inherit", "pipe"], }) - agent.stderr.pipe(split2()).on("data", line => { + agent.stderr.pipe(split2()).on("data", (line) => { line = line.replace(/^[0-9-]+ [0-9:]+ [^ ]+\t/, "") logger.info(line) }) @@ -22,7 +22,7 @@ export async function coderCloudExpose(serverName: string): Promise { return new Promise((res, rej) => { agent.on("error", rej) - agent.on("close", code => { + agent.on("close", (code) => { if (code !== 0) { rej({ message: `coder cloud agent exited with ${code}`, @@ -54,7 +54,7 @@ export function coderCloudProxy(addr: string) { stdio: ["inherit", "inherit", "pipe"], }) - agent.stderr.pipe(split2()).on("data", line => { + agent.stderr.pipe(split2()).on("data", (line) => { line = line.replace(/^[0-9-]+ [0-9:]+ [^ ]+\t/, "") logger.info(line) }) @@ -62,7 +62,7 @@ export function coderCloudProxy(addr: string) { return new Promise((res, rej) => { agent.on("error", rej) - agent.on("close", code => { + agent.on("close", (code) => { if (code !== 0) { rej({ message: `coder cloud agent exited with ${code}`, @@ -77,7 +77,7 @@ export function coderCloudProxy(addr: string) { const proxy = async () => { try { await _proxy() - } catch(err) { + } catch (err) { logger.error(err.message) } setTimeout(proxy, 3000)