Archived
1
0

Adhere to XDG base directory spec for dataDir and logDir (#156)

This commit is contained in:
Forest Hoffman
2019-03-09 11:11:30 -06:00
committed by Kyle Carberry
parent e22e2c8b67
commit 30d14eeab4
2 changed files with 13 additions and 3 deletions

View File

@ -12,7 +12,7 @@ import { requireModule, requireFork, forkModule } from "./vscode/bootstrapFork";
import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
import { setup as setupNativeModules } from "./modules";
import { fillFs } from "./fill";
import { isCli, serveStatic, buildDir } from "./constants";
import { isCli, serveStatic, buildDir, dataHome, cacheHome } from "./constants";
import opn = require("opn");
export class Entry extends Command {
@ -49,7 +49,7 @@ export class Entry extends Command {
}
const { args, flags } = this.parse(Entry);
const dataDir = path.resolve(flags["data-dir"] || path.join(os.homedir(), ".code-server"));
const dataDir = path.resolve(flags["data-dir"] || path.join(dataHome, "code-server"));
const workingDir = path.resolve(args["workdir"]);
setupNativeModules(dataDir);
@ -81,7 +81,11 @@ export class Entry extends Command {
fs.mkdirSync(dataDir);
}
const logDir = path.join(dataDir, "logs", new Date().toISOString().replace(/[-:.TZ]/g, ""));
if (!fs.existsSync(cacheHome)) {
fs.mkdirSync(cacheHome);
}
const logDir = path.join(cacheHome, "code-server/logs", new Date().toISOString().replace(/[-:.TZ]/g, ""));
process.env.VSCODE_LOGS = logDir;
const certPath = flags.cert ? path.resolve(flags.cert) : undefined;