1 |
|
2 | const chalk = require('chalk')
|
3 | const Gmail = require('./gmail')
|
4 | const db = require('./db')
|
5 | const auth = require('./auth')
|
6 |
|
7 | const clear = () => {
|
8 | db.set('messages', []).set('pages', {}).write()
|
9 | }
|
10 |
|
11 | async function init () {
|
12 | clear()
|
13 | let accounts = db.get('prefs.accounts').value()
|
14 | if (accounts) {
|
15 | await (new Gmail(accounts)).homeMenu()
|
16 | } else {
|
17 | console.log(chalk.bold('Authorizing...'))
|
18 | await auth()
|
19 | require('./server')
|
20 | }
|
21 | }
|
22 |
|
23 | init()
|