Skip to content

Commit

Permalink
Fixed: user detection for fix-perm on windows #94, config require error
Browse files Browse the repository at this point in the history
Release: v1.2.0-rc2
  • Loading branch information
vervallsweg committed Apr 22, 2019
1 parent 56c2d2a commit dc135f9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ client_secret.json
tokens.json
.idea
*.heapsnapshot
callbacks.json
config.json
callbacks.json
15 changes: 10 additions & 5 deletions lib/config/assistant-setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const jsonfile = require('jsonfile');
const OAuth2 = new (require('google-auth-library'))().OAuth2;
const Config = require('./config');

class AssistantSetup {
static checkSetup() {
Expand All @@ -17,7 +16,7 @@ class AssistantSetup {
}
}

let file = Config.getAbsolutePath()+'/config/tokens.json';
let file = AssistantSetup.getAbsolutePath()+'/config/tokens.json';
jsonfile.readFile(file, function(err, obj) {
if (obj) {
if (obj.access_token) {
Expand Down Expand Up @@ -90,7 +89,7 @@ class AssistantSetup {

static writeClientSecretJSON(object) {
return new Promise(resolve => {
let file = Config.getAbsolutePath()+'/config/client_secret.json';
let file = AssistantSetup.getAbsolutePath()+'/config/client_secret.json';

jsonfile.writeFileSync(file, object, function (err) {
if (err) {
Expand All @@ -103,7 +102,7 @@ class AssistantSetup {

static readClientSecretJSON() {
return new Promise( function(resolve, reject) {
let file = Config.getAbsolutePath()+'/config/client_secret.json';
let file = AssistantSetup.getAbsolutePath()+'/config/client_secret.json';

jsonfile.readFile(file, function(err, obj) {
if (obj) {
Expand Down Expand Up @@ -149,7 +148,7 @@ class AssistantSetup {
}

static writeToken(token) {
let file = Config.getAbsolutePath()+'/config/tokens.json';
let file = AssistantSetup.getAbsolutePath()+'/config/tokens.json';
console.log('writeToken: '+JSON.stringify(token));

jsonfile.writeFile(file, token, function(err) {
Expand Down Expand Up @@ -186,6 +185,12 @@ class AssistantSetup {
})
});
}

static getAbsolutePath(){ //TODO: get rid of redundancy in /lib/config
let path = (require.resolve('../../castWebApi.js').substring(0, ( require.resolve('../../castWebApi.js').length -14 ) ));
// console.log(path);
return path;
}
}

module.exports = AssistantSetup;
2 changes: 1 addition & 1 deletion manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class Manager {
return new Promise((resolve, reject) => {
let windows = process.platform === "win32";
let Config = require('./lib/config/config');
let user = process.env.USER;
let user = process.env.USER || process.env.USERNAME;
let path = Config.getAbsolutePath();

if (!windows) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cast-web-api",
"version": "1.2.0-rc1",
"version": "1.2.0-rc2",
"author": "Tobias Haerke",
"engines": {
"node": ">= 7.0.0"
Expand Down

0 comments on commit dc135f9

Please sign in to comment.