Created
August 9, 2018 04:32
-
-
Save Tolsee/4056b6929ea7bd621c89fbb2004c50a5 to your computer and use it in GitHub Desktop.
Read, write operation in json file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const readConfig = () => { | |
const rawConfig = fs.readFileSync(path.join(__dirname, 'config.json'), 'utf8'); | |
return JSON.parse(rawConfig); | |
}; | |
module.exports.readConfig = readConfig; | |
module.exports.writeConfig = (config) => { | |
fs.writeFileSync(path.join(__dirname, 'config.json'), JSON.stringify(config), 'utf8'); | |
}; | |
module.exports.checkAuth = () => { | |
return !!readConfig().access_token; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment