Skip to content

Commit 4d67771

Browse files
authored
Merge pull request #106 from atsushifx/bugfix/105-wakatime-home-ignored
fix(config): respect WAKATIME_HOME env for config file location (#105)
2 parents cce2f3f + 56bf130 commit 4d67771

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

electron/helpers/config-file.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import path from "node:path";
2-
import { app } from "electron";
32

4-
import { getResourcesFolderPath } from "../utils";
3+
import { getResourcesFolderPath, getWakatimeHome } from "../utils";
54
import { ConfigFileReader } from "./config-file-reader";
65

76
export abstract class ConfigFile {
87
static getConfigFilePath(internalConfig = false) {
8+
const userHome = getWakatimeHome();
99
if (internalConfig) {
1010
return path.join(getResourcesFolderPath(), "wakatime-internal.cfg");
1111
} else {
12-
const userHome = app.getPath("home");
1312
return path.join(userHome, ".wakatime.cfg");
1413
}
1514
}

electron/utils/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import { execFile } from "node:child_process";
22
import fs from "node:fs";
33
import path from "node:path";
44
import { app } from "electron";
5+
import process from "node:process";
56

67
import { WAKATIME_PROTOCALL } from "./constants";
78

9+
export function getWakatimeHome(): string {
10+
const envHome = process.env["WAKATIME_HOME"] || app.getPath("home");
11+
return envHome.trim();
12+
}
13+
814
export function getResourcesFolderPath() {
9-
const userHome = app.getPath("home");
15+
const userHome = getWakatimeHome();
1016

1117
const resourcesFolder = path.join(userHome, ".wakatime");
1218

0 commit comments

Comments
 (0)