Created
November 7, 2019 06:56
-
-
Save john-osullivan/534d2f51f6708e6cab64eb3d47e1d075 to your computer and use it in GitHub Desktop.
Dev Diary #3 - CLI authStorage
This file contains 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
import { AuthData, newAuthData } from '@eximchain/dappbot-types/spec/user'; | |
export const AUTH_FILENAME = 'dappbotAuthData.json'; | |
export const AUTH_FILE_PATH = path.resolve(__dirname, `./${AUTH_FILENAME}`); | |
export function initAuthFile() { | |
if (!fs.existsSync(AUTH_FILE_PATH)) { | |
fs.writeFileSync(AUTH_FILE_PATH, JSON.stringify(newAuthData(), null, 2)); | |
} | |
} | |
export function saveAuthToFile(newData:AuthData) { | |
fs.writeFileSync(AUTH_FILE_PATH, JSON.stringify(newData, null, 2)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment