code-server/packages/ide/src/fill/os.ts
Kyle Carberry e8174095ca
Add windows support (#41)
* Add windows support

* Improve multi-platform support

* Install with network-concurrency 1

* Use file-glob to upload windows binary

* Don't install packages in parallel if on windows

* Rename vscode-remote to code-server

* Add output at intervals so CI doesn't kill build

* Update all tasks to provide timed output

* Don't perform tasks sync otherwise we can't log
2019-02-28 14:04:19 -06:00

54 lines
1.3 KiB
TypeScript

import { OperatingSystem, InitData } from "@coder/protocol";
import { client } from "./client";
class OS {
private _homedir: string | undefined;
private _tmpdir: string | undefined;
private _platform: NodeJS.Platform | undefined;
public constructor() {
client.initData.then((d) => this.initialize(d));
}
public homedir(): string {
if (typeof this._homedir === "undefined") {
throw new Error("trying to access homedir before it has been set");
}
return this._homedir;
}
public tmpdir(): string {
if (typeof this._tmpdir === "undefined") {
throw new Error("trying to access tmpdir before it has been set");
}
return this._tmpdir;
}
public initialize(data: InitData): void {
this._homedir = data.homeDirectory;
this._tmpdir = data.tmpDirectory;
switch (data.os) {
case OperatingSystem.Windows: this._platform = "win32"; break;
case OperatingSystem.Mac: this._platform = "darwin"; break;
default: this._platform = "linux"; break;
}
process.platform = this._platform;
}
public release(): string {
return "Unknown";
}
public platform(): NodeJS.Platform {
if (typeof this._platform === "undefined") {
throw new Error("trying to access platform before it has been set");
}
return this._platform;
}
}
export = new OS();