mirror of https://git.tuxpa.in/a/code-server.git
Rename dir to workspaceDir
This commit is contained in:
parent
2e001f24f8
commit
092bfaaff4
|
@ -28,14 +28,14 @@ describe("CodeServer", true, [], () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test("should open a file", async ({ codeServerPage }) => {
|
test("should open a file", async ({ codeServerPage }) => {
|
||||||
const dir = await codeServerPage.dir()
|
const dir = await codeServerPage.workspaceDir
|
||||||
const file = path.join(dir, "foo")
|
const file = path.join(dir, "foo")
|
||||||
await fs.writeFile(file, "bar")
|
await fs.writeFile(file, "bar")
|
||||||
await codeServerPage.openFile(file)
|
await codeServerPage.openFile(file)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("should not share state with other paths", async ({ codeServerPage }) => {
|
test("should not share state with other paths", async ({ codeServerPage }) => {
|
||||||
const dir = await codeServerPage.dir()
|
const dir = await codeServerPage.workspaceDir
|
||||||
const file = path.join(dir, "foo")
|
const file = path.join(dir, "foo")
|
||||||
await fs.writeFile(file, "bar")
|
await fs.writeFile(file, "bar")
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ export class CodeServer {
|
||||||
private process: Promise<CodeServerProcess> | undefined
|
private process: Promise<CodeServerProcess> | undefined
|
||||||
public readonly logger: Logger
|
public readonly logger: Logger
|
||||||
private closed = false
|
private closed = false
|
||||||
private workspaceDir: Promise<string> | undefined
|
private _workspaceDir: Promise<string> | undefined
|
||||||
|
|
||||||
constructor(name: string, private readonly codeServerArgs: string[]) {
|
constructor(name: string, private readonly codeServerArgs: string[]) {
|
||||||
this.logger = logger.named(name)
|
this.logger = logger.named(name)
|
||||||
|
@ -55,18 +55,21 @@ export class CodeServer {
|
||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
async dir(): Promise<string> {
|
/**
|
||||||
if (!this.workspaceDir) {
|
* The workspace directory code-server opens with.
|
||||||
this.workspaceDir = tmpdir(workspaceDir)
|
*/
|
||||||
|
get workspaceDir(): Promise<string> {
|
||||||
|
if (!this._workspaceDir) {
|
||||||
|
this._workspaceDir = tmpdir(workspaceDir)
|
||||||
}
|
}
|
||||||
return this.workspaceDir
|
return this._workspaceDir
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a random workspace and seed it with settings.
|
* Create a random workspace and seed it with settings.
|
||||||
*/
|
*/
|
||||||
private async createWorkspace(): Promise<string> {
|
private async createWorkspace(): Promise<string> {
|
||||||
const dir = await this.dir()
|
const dir = await this.workspaceDir
|
||||||
await fs.mkdir(path.join(dir, "User"))
|
await fs.mkdir(path.join(dir, "User"))
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
path.join(dir, "User/settings.json"),
|
path.join(dir, "User/settings.json"),
|
||||||
|
@ -198,8 +201,11 @@ export class CodeServerPage {
|
||||||
return this.codeServer.address()
|
return this.codeServer.address()
|
||||||
}
|
}
|
||||||
|
|
||||||
dir() {
|
/**
|
||||||
return this.codeServer.dir()
|
* The workspace directory code-server opens with.
|
||||||
|
*/
|
||||||
|
get workspaceDir() {
|
||||||
|
return this.codeServer.workspaceDir
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue