Skip to content

Instantly share code, notes, and snippets.

@john-osullivan
Created November 7, 2019 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-osullivan/534d2f51f6708e6cab64eb3d47e1d075 to your computer and use it in GitHub Desktop.
Save john-osullivan/534d2f51f6708e6cab64eb3d47e1d075 to your computer and use it in GitHub Desktop.
Dev Diary #3 - CLI authStorage
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