Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3c10163
Flesh out fixes to align with upstream.
GirlBossRush Oct 28, 2021
0e7eb7e
Update route handlers to better reflect fallback behavior.
GirlBossRush Oct 29, 2021
ad787bb
Bump vendor.
GirlBossRush Oct 29, 2021
19c9c23
Touch up build, tests.
GirlBossRush Oct 29, 2021
062ce32
bump vscode.
GirlBossRush Nov 4, 2021
2481711
Add platform to vscode-reh-web task
code-asher Nov 4, 2021
dde9a08
Fix issue where workspace args are not parsed.
GirlBossRush Nov 4, 2021
26733fd
Update CLI test.
GirlBossRush Nov 4, 2021
059893f
Update CLI tests.
GirlBossRush Nov 4, 2021
9945428
Fix issues surrounding opening files within code-server's terminal.
GirlBossRush Nov 4, 2021
93adec7
Bump vendor.
GirlBossRush Nov 4, 2021
28e0d78
Update VS Code
code-asher Nov 5, 2021
4cf13f4
Merge remote-tracking branch 'origin/main' into upstream-server-fixes
code-asher Nov 5, 2021
76e6ccc
Readd parent wrapper for hot reload.
GirlBossRush Nov 5, 2021
efada23
Allow more errors.
GirlBossRush Nov 5, 2021
1f7e8a1
Bump vscode.
GirlBossRush Nov 5, 2021
914aad2
Fix issues surrounding Coder link.
GirlBossRush Nov 5, 2021
a413abf
Add dir creation and fix cli
code-asher Nov 5, 2021
55d878e
Remove hardcoded VSCODE_DEV=1
code-asher Nov 8, 2021
d03c9f5
Fix mismatching commit between client and server
code-asher Nov 8, 2021
8244463
Mostly restore command-line parity
code-asher Nov 8, 2021
d5ed30f
Fix static endpoint not emitting 404s
code-asher Nov 8, 2021
30b9923
Update VS Code
code-asher Nov 8, 2021
a281ccd
Import missing logError
code-asher Nov 9, 2021
7d48b82
Fix 403 errors
code-asher Nov 9, 2021
fc94ac9
Add code-server version to about dialog
code-asher Nov 9, 2021
89cc5a9
Use user settings to disable welcome page
code-asher Nov 10, 2021
e022788
Update VS Code cache step with new build directories
code-asher Nov 10, 2021
c8f2b12
Merge branch 'main' into upstream-server-fixes
code-asher Nov 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix issue where workspace args are not parsed.
  • Loading branch information
GirlBossRush committed Nov 4, 2021
commit dde9a08c6747a6703da0d255c98e043b72474bc7
30 changes: 24 additions & 6 deletions src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import { promises as fs } from "fs"
import yaml from "js-yaml"
import * as os from "os"
import * as path from "path"
import { canConnect, generateCertificate, generatePassword, humanPath, paths, isNodeJSErrnoException } from "./util"
import {
canConnect,
generateCertificate,
generatePassword,
humanPath,
paths,
isNodeJSErrnoException,
isFile,
} from "./util"

const DEFAULT_SOCKET_PATH = path.join(os.tmpdir(), "vscode-ipc")

Expand Down Expand Up @@ -282,12 +290,12 @@ export const createDefaultArgs = (): Args => {
}
}

export const parse = (
export const parse = async (
argv: string[],
opts?: {
configFile?: string
},
): Args => {
): Promise<Args> => {
const error = (msg: string): Error => {
if (opts?.configFile) {
msg = `error reading ${opts.configFile}: ${msg}`
Expand All @@ -296,7 +304,6 @@ export const parse = (
return new Error(msg)
}

// TODO: parse workspace and folder.
const args: Args = createDefaultArgs()
let ended = false

Expand Down Expand Up @@ -399,6 +406,17 @@ export const parse = (
args._.push(arg)
}

if (args._.length && !args.folder && !args.workspace) {
const firstEntry = path.resolve(process.cwd(), args._[0])

if ((await isFile(firstEntry)) && path.extname(firstEntry) === ".code-workspace") {
args.workspace = firstEntry
args._.shift()
} else {
args.folder = args._.join(" ")
}
}

// If a cert was provided a key must also be provided.
if (args.cert && args.cert.value && !args["cert-key"]) {
throw new Error("--cert-key is missing")
Expand Down Expand Up @@ -591,7 +609,7 @@ export async function readConfigFile(configPath?: string): Promise<ConfigArgs> {
* parseConfigFile parses configFile into ConfigArgs.
* configPath is used as the filename in error messages
*/
export function parseConfigFile(configFile: string, configPath: string): ConfigArgs {
export async function parseConfigFile(configFile: string, configPath: string): Promise<ConfigArgs> {
if (!configFile) {
return { ...createDefaultArgs(), config: configPath }
}
Expand All @@ -611,7 +629,7 @@ export function parseConfigFile(configFile: string, configPath: string): ConfigA
}
return `--${optName}=${opt}`
})
const args = parse(configFileArgv, {
const args = await parse(configFileArgv, {
configFile: configPath,
})
return {
Expand Down
4 changes: 3 additions & 1 deletion src/node/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ async function entry(): Promise<void> {
return
}

const cliArgs = parse(process.argv.slice(2))
const cliArgs = await parse(process.argv.slice(2))
const configArgs = await readConfigFile(cliArgs.config)
const args = await setDefaults(cliArgs, configArgs)

if (args.help) {
console.log("code-server", version, commit)
console.log("")
console.log(`Usage: code-server [options] [path]`)
console.log(` - Opening a directory: code-server ./path/to/your/project`)
console.log(` - Opening a saved workspace: code-server ./path/to/your/project.code-workspace`)
console.log("")
console.log("Options")
optionDescriptions().forEach((description) => {
Expand Down
10 changes: 8 additions & 2 deletions src/node/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,17 @@ export const runCodeServer = async (
}

const app = await createApp(args)
const serverAddress = ensureAddress(app.server, args.cert ? "https" : "http")
const protocol = args.cert ? "https" : "http"
const serverAddress = ensureAddress(app.server, protocol)
const disposeRoutes = await register(app, args)

logger.info(`Using config file ${humanPath(args.config)}`)
logger.info(`HTTP server listening on ${serverAddress.toString()} ${args.link ? "(randomized by --link)" : ""}`)
logger.info(
`${protocol.toUpperCase()} server listening on ${serverAddress.toString()} ${
args.link ? "(randomized by --link)" : ""
}`,
)

if (args.auth === AuthType.Password) {
logger.info(" - Authentication is enabled")
if (args.usingEnvPassword) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/models/CodeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class CodeServer {
if (resolved) {
return
}
const match = line.trim().match(/HTTP server listening on (https?:\/\/[.:\d]+)\/?$/)
const match = line.trim().match(/HTTPS? server listening on (https?:\/\/[.:\d]+)\/?$/)
if (match) {
// Cookies don't seem to work on IP address so swap to localhost.
// TODO: Investigate whether this is a bug with code-server.
Expand Down