Skip to content

Commit

Permalink
fix #72
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskbx committed Oct 4, 2018
1 parent 565d24e commit cec2a90
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ yarn global add gitlab-time-tracker --prefix /usr/local

Run the config command to create a config file and open it in your default editor.
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).
If nothing happens, open the file manually: `~/.gtt/config.yml` - on Windows: `C:\Users\YourUserName\.gtt\config.yml`
If nothing happens, open the file manually: `~/.local/share/.gtt` - on Windows: `C:\Users\YourUserName\.gtt\config.yml`

```shell
gtt config
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"request-promise-native": "^1.0.4",
"tempfile": "^2.0.0",
"underscore": "^1.9.1",
"xdg-basedir": "^3.0.0",
"xlsx": "^0.13.5"
},
"devDependencies": {
Expand Down
11 changes: 10 additions & 1 deletion src/include/file-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs');
const path = require('path');
const os = require("os");
const xdgBaseDir = require('xdg-basedir');
const config = require('./config');
const yaml = require('read-yaml');
const hash = require('hash-sum');
Expand Down Expand Up @@ -84,6 +85,10 @@ class fileConfig extends config {
}

assertGlobalConfig() {
if(!fs.existsSync(this.globalDir) && fs.existsSync(this.oldGlobalDir)) {
fs.renameSync(this.oldGlobalDir, this.globalDir);
}

if (!fs.existsSync(this.globalDir)) fs.mkdirSync(this.globalDir, '0750', true);
if (!fs.existsSync(this.frameDir)) fs.mkdirSync(this.frameDir, '0750', true);
if (!fs.existsSync(this.cacheDir)) fs.mkdirSync(this.cacheDir, '0750', true);
Expand Down Expand Up @@ -114,10 +119,14 @@ class fileConfig extends config {
return '.gtt.yml';
}

get globalDir() {
get oldGlobalDir() {
return Fs.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], '.gtt');
}

get globalDir() {
return Fs.join(xdgBaseDir.data, '.gtt');
}

get frameDir() {
return Fs.join(this.globalDir, 'frames');
}
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,10 @@ [email protected]:
version "1.3.9"
resolved "https://registry.yarnpkg.com/wrench/-/wrench-1.3.9.tgz#6f13ec35145317eb292ca5f6531391b244111411"

xdg-basedir@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"

xlsx@^0.13.5:
version "0.13.5"
resolved "https://registry.yarnpkg.com/xlsx/-/xlsx-0.13.5.tgz#65826ba1944c6f4d6c023b7eb6c89e6b6e0d71b7"
Expand Down

0 comments on commit cec2a90

Please sign in to comment.