Fixes for CI

This commit is contained in:
Anmol Sethi 2020-09-09 00:06:28 -04:00
parent 55a7e8b56f
commit 0aa98279d6
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB
2 changed files with 31 additions and 25 deletions

View File

@ -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<T> {
@ -131,7 +131,8 @@ const options: Options<Required<Args>> = {
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" +
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": {
@ -158,13 +159,13 @@ const options: Options<Required<Args>> = {
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) => {
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) {
if (i === 0) {
return " ".repeat(widths.long - k.length) + line
}
return " ".repeat(widths.long + widths.short + 6) + line
}).join("\n")
},
})
.join("\n")
)
})
}
export const parse = (

View File

@ -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<void> {
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<void> {
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)