Skip to content

Commit 8dcc1e3

Browse files
committed
Accept argument to change initial working directory
1 parent e22791e commit 8dcc1e3

File tree

3 files changed

+46
-26
lines changed

3 files changed

+46
-26
lines changed

README.md

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
[![MIT license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cdr/code-server/blob/master/LICENSE)
66
[![Discord](https://img.shields.io/discord/463752820026376202.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/zxSwN8Z)
77

8-
`code-server` is [VS Code](https://github.com/Microsoft/vscode) running on a remote server, accessible through the browser.
8+
`code-server` is [VS Code](https://github.com/Microsoft/vscode) running on a
9+
remote server, accessible through the browser.
910

1011
Try it out:
1112
```bash
1213
docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/code-server --allow-http --no-auth
1314
```
1415

1516
- Code on your Chromebook, tablet, and laptop with a consistent dev environment.
16-
- If you have a Windows or Mac workstation, more easily develop for Linux.
17+
- If you have a Windows or Mac workstation, more easily develop for Linux.
1718
- Take advantage of large cloud servers to speed up tests, compilations, downloads, and more.
1819
- Preserve battery life when you're on the go.
19-
- All intensive computation runs on your server.
20-
- You're no longer running excess instances of Chrome.
20+
- All intensive computation runs on your server.
21+
- You're no longer running excess instances of Chrome.
2122

2223
![Screenshot](/doc/assets/ide.png)
2324

@@ -29,28 +30,35 @@ Use [sshcode](https://github.com/codercom/sshcode) for a simple setup.
2930

3031
### Docker
3132

32-
See docker oneliner mentioned above. Dockerfile is at [/Dockerfile](/Dockerfile).
33+
See docker oneliner mentioned above. Dockerfile is at
34+
[/Dockerfile](/Dockerfile).
3335

3436
### Binaries
3537

36-
1. [Download a binary](https://github.com/cdr/code-server/releases) (Linux and OS X supported. Windows coming soon)
38+
1. [Download a binary](https://github.com/cdr/code-server/releases) (Linux and
39+
OS X supported. Windows coming soon)
3740
2. Start the binary with the project directory as the first argument
3841

39-
```
40-
code-server <initial directory to open>
41-
```
42-
> You will be prompted to enter the password shown in the CLI
43-
`code-server` should now be running at https://localhost:8443.
42+
```
43+
code-server <initial directory to open>
44+
```
45+
You will be prompted to enter the password shown in the CLI. `code-server`
46+
should now be running at https://localhost:8443.
4447

45-
> code-server uses a self-signed SSL certificate that may prompt your browser to ask you some additional questions before you proceed. Please [read here](doc/self-hosted/index.md) for more information.
48+
`code-server` uses a self-signed SSL certificate that may prompt your
49+
browser to ask you some additional questions before you proceed. Please
50+
[read here](doc/self-hosted/index.md) for more information.
4651

47-
For detailed instructions and troubleshooting, see the [self-hosted quick start guide](doc/self-hosted/index.md).
52+
For detailed instructions and troubleshooting, see the
53+
[self-hosted quick start guide](doc/self-hosted/index.md).
4854

49-
Quickstart guides for [Google Cloud](doc/admin/install/google_cloud.md), [AWS](doc/admin/install/aws.md), and [DigitalOcean](doc/admin/install/digitalocean.md).
55+
Quickstart guides for [Google Cloud](doc/admin/install/google_cloud.md),
56+
[AWS](doc/admin/install/aws.md), and
57+
[DigitalOcean](doc/admin/install/digitalocean.md).
5058

5159
How to [secure your setup](/doc/security/ssl.md).
5260

53-
## Build
61+
### Build
5462
- If you also plan on developing, set the `OUT` environment variable: `
5563
export OUT=/path/to/some/directory`. Otherwise it will build in this
5664
directory which will cause issues because then `yarn watch` will try to
@@ -62,7 +70,7 @@ How to [secure your setup](/doc/security/ssl.md).
6270
`yarn binary` with the same arguments in the previous step to package the
6371
code into a single binary.
6472

65-
## Development
73+
### Development
6674

6775
```fish
6876
git clone https://github.com/microsoft/vscode
@@ -77,25 +85,31 @@ yarn start --allow-http --no-auth
7785
# Visit http://localhost:8443
7886
```
7987

80-
### Known Issues
88+
## Known Issues
8189

8290
- Creating custom VS Code extensions and debugging them doesn't work.
83-
- To debug Golang using [ms-vscode-go extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go), you need to add `--security-opt seccomp=unconfined` to your `docker run` arguments when launching code-server with Docker. See [#725](https://github.com/cdr/code-server/issues/725) for details.
91+
- To debug Golang using
92+
[ms-vscode-go extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go),
93+
you need to add `--security-opt seccomp=unconfined` to your `docker run`
94+
arguments when launching code-server with Docker. See
95+
[#725](https://github.com/cdr/code-server/issues/725) for details.
8496

85-
### Future
97+
## Future
8698
- **Stay up to date!** Get notified about new releases of code-server.
8799
![Screenshot](/doc/assets/release.gif)
88100
- Windows support.
89101
- Electron and Chrome OS applications to bridge the gap between local<->remote.
90102
- Run VS Code unit tests against our builds to ensure features work as expected.
91103

92-
### Extensions
104+
## Extensions
93105

94-
At the moment we can't use the official VSCode Marketplace. We've created a custom extension marketplace focused around open-sourced extensions. However, if you have access to the `.vsix` file, you can manually install the extension.
106+
At the moment we can't use the official VSCode Marketplace. We've created a
107+
custom extension marketplace focused around open-sourced extensions. However,
108+
if you have access to the `.vsix` file, you can manually install the extension.
95109

96110
## Telemetry
97111

98-
Use the `--disable-telemetry` flag or set `DISABLE_TELEMETRY=true` to disable tracking ENTIRELY.
112+
Set the `telemetry.enableTelemetry` user setting to false to disable telemetry.
99113

100114
We use data collected to improve code-server.
101115

@@ -109,8 +123,10 @@ Development guides are coming soon.
109123

110124
## Enterprise
111125

112-
Visit [our enterprise page](https://coder.com/enterprise) for more information about our enterprise offering.
126+
Visit [our enterprise page](https://coder.com/enterprise) for more information
127+
about our enterprise offering.
113128

114129
## Commercialization
115130

116-
If you would like to commercialize code-server, please contact [email protected].
131+
If you would like to commercialize code-server, please contact
132+

src/cli.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ const main = async (): Promise<void> => {
127127
certKey: args["cert-key"],
128128
auth: typeof args.auth !== "undefined" ? args.auth : true,
129129
password: process.env.PASSWORD,
130+
folderUri: args["_"] && args["_"].length > 1
131+
? args["_"][args["_"].length - 1]
132+
: undefined,
130133
};
131134

132135
if (!options.host) {

src/server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export interface ServerOptions {
9797
readonly certKey?: string;
9898
readonly auth?: boolean;
9999
readonly password?: string;
100+
readonly folderUri?: string;
100101
}
101102

102103
export abstract class Server {
@@ -107,7 +108,7 @@ export abstract class Server {
107108

108109
private listenPromise: Promise<string> | undefined;
109110

110-
public constructor(private readonly options: ServerOptions) {
111+
public constructor(protected readonly options: ServerOptions) {
111112
if (this.options.cert && this.options.certKey) {
112113
useHttpsTransformer();
113114
const httpolyglot = require.__$__nodeRequire(path.resolve(__dirname, "../node_modules/httpolyglot/lib/index")) as typeof import("httpolyglot");
@@ -458,7 +459,7 @@ export class MainServer extends Server {
458459

459460
const cwd = process.env.VSCODE_CWD || process.cwd();
460461
const workspacePath = parsedUrl.query.workspace as string | undefined;
461-
const folderPath = !workspacePath ? parsedUrl.query.folder as string | undefined || cwd: undefined;
462+
const folderPath = !workspacePath ? parsedUrl.query.folder as string | undefined || this.options.folderUri || cwd: undefined;
462463

463464
const options: Options = {
464465
WORKBENCH_WEB_CONGIGURATION: {

0 commit comments

Comments
 (0)