Skip to content

Commit 12cdda1

Browse files
committed
[WIP] home dir
1 parent c7fd72f commit 12cdda1

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/server/server.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ namespace ts.server {
1111

1212
interface NodeChildProcess {
1313
send(message: any, sendHandle?: any): void;
14+
on(message: "message", f: (m: any) => void): void;
1415
}
1516

1617
const childProcess: {
1718
fork(modulePath: string): NodeChildProcess;
1819
} = require("child_process");
1920

21+
const os: {
22+
homedir(): string
23+
} = require("os");
24+
2025
interface ReadLineOptions {
2126
input: NodeJS.ReadableStream;
2227
output?: NodeJS.WritableStream;
@@ -165,14 +170,20 @@ namespace ts.server {
165170
private cachePath: string;
166171

167172
constructor(private readonly logger: server.Logger) {
173+
let basePath: string;
168174
switch (process.platform) {
169175
case "win32":
170-
this.cachePath = normalizeSlashes(combinePaths(process.env.LOCALAPPDATA || process.env.APPDATA, "Microsoft/TypeScript"));
176+
basePath = process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir();
171177
break;
172-
case "darwin":
173178
case "linux":
174-
// TODO:
179+
basePath = os.homedir();
175180
break;
181+
case "darwin":
182+
basePath = combinePaths(os.homedir(), "/Library/Application Support/")
183+
break;
184+
}
185+
if (basePath) {
186+
this.cachePath = combinePaths(normalizeSlashes(basePath), "/Microsoft/TypeScript");
176187
}
177188
}
178189

@@ -183,7 +194,7 @@ namespace ts.server {
183194
}
184195

185196
this.installer = childProcess.fork(combinePaths(__dirname, "typingsInstaller.js"));
186-
(<any>this.installer).on("message", (m: any) => this.handleMessage(m));
197+
this.installer.on("message", m => this.handleMessage(m));
187198
}
188199

189200
enqueueInstallTypingsRequest(project: Project, typingOptions: TypingOptions): void {

0 commit comments

Comments
 (0)