Skip to content

Commit

Permalink
really ?
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsounet committed Jun 21, 2024
1 parent d801fa9 commit 407b024
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,14 @@ module.exports = {
/* from MMM-Netatmo
* @bugsounet
*/
readToken: function() {
var refresh_token = null
var file = path.resolve(__dirname, "./token.json")
readToken: function () {
var file = path.resolve(__dirname, './token.json')
// check presence of token.json
if (fs.existsSync(file)) {
let tokenFile = JSON.parse(fs.readFileSync(file))
refresh_token = tokenFile.refresh_token
const refresh_token = tokenFile.refresh_token
if (!refresh_token) {
console.error("Token not found in token.json file")
console.error('Token not found in token.json file')
return null
}
return refresh_token
Expand All @@ -152,15 +151,15 @@ module.exports = {
return null
},

writeToken: function(token) {
writeToken: function (token) {
try {
var file = path.resolve(__dirname, "./token.json")
const file = path.resolve(__dirname, './token.json')
fs.writeFileSync(file, JSON.stringify(token))
console.log("netatmo token.json was written successfully")
console.log('netatmo token.json was written successfully')
return token
} catch (error) {
console.error("netatmo token.json writeToken error", error.message)
console.error('netatmo token.json writeToken error', error.message)
return null
}
}
},
}

0 comments on commit 407b024

Please sign in to comment.