Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit cec2a90

Browse files
committed
fix #72
1 parent 565d24e commit cec2a90

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ yarn global add gitlab-time-tracker --prefix /usr/local
3737

3838
Run the config command to create a config file and open it in your default editor.
3939
In linux terminal, you must set your preferred editor in the environment. For example, use `export EDITOR=vim` to edit the files with vim (put this in `.bashrc` or similar to have it always configured).
40-
If nothing happens, open the file manually: `~/.gtt/config.yml` - on Windows: `C:\Users\YourUserName\.gtt\config.yml`
40+
If nothing happens, open the file manually: `~/.local/share/.gtt` - on Windows: `C:\Users\YourUserName\.gtt\config.yml`
4141

4242
```shell
4343
gtt config

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"request-promise-native": "^1.0.4",
4949
"tempfile": "^2.0.0",
5050
"underscore": "^1.9.1",
51+
"xdg-basedir": "^3.0.0",
5152
"xlsx": "^0.13.5"
5253
},
5354
"devDependencies": {

src/include/file-config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs');
22
const path = require('path');
33
const os = require("os");
4+
const xdgBaseDir = require('xdg-basedir');
45
const config = require('./config');
56
const yaml = require('read-yaml');
67
const hash = require('hash-sum');
@@ -84,6 +85,10 @@ class fileConfig extends config {
8485
}
8586

8687
assertGlobalConfig() {
88+
if(!fs.existsSync(this.globalDir) && fs.existsSync(this.oldGlobalDir)) {
89+
fs.renameSync(this.oldGlobalDir, this.globalDir);
90+
}
91+
8792
if (!fs.existsSync(this.globalDir)) fs.mkdirSync(this.globalDir, '0750', true);
8893
if (!fs.existsSync(this.frameDir)) fs.mkdirSync(this.frameDir, '0750', true);
8994
if (!fs.existsSync(this.cacheDir)) fs.mkdirSync(this.cacheDir, '0750', true);
@@ -114,10 +119,14 @@ class fileConfig extends config {
114119
return '.gtt.yml';
115120
}
116121

117-
get globalDir() {
122+
get oldGlobalDir() {
118123
return Fs.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], '.gtt');
119124
}
120125

126+
get globalDir() {
127+
return Fs.join(xdgBaseDir.data, '.gtt');
128+
}
129+
121130
get frameDir() {
122131
return Fs.join(this.globalDir, 'frames');
123132
}

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,10 @@ [email protected]:
25292529
version "1.3.9"
25302530
resolved "https://registry.yarnpkg.com/wrench/-/wrench-1.3.9.tgz#6f13ec35145317eb292ca5f6531391b244111411"
25312531

2532+
xdg-basedir@^3.0.0:
2533+
version "3.0.0"
2534+
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"
2535+
25322536
xlsx@^0.13.5:
25332537
version "0.13.5"
25342538
resolved "https://registry.yarnpkg.com/xlsx/-/xlsx-0.13.5.tgz#65826ba1944c6f4d6c023b7eb6c89e6b6e0d71b7"

0 commit comments

Comments
 (0)