UNPKG

839 BJavaScriptView Raw
1function print () {
2 'use strong'
3
4 const path = require('path')
5 const chalk = require('chalk')
6 const osHomeDir = require('os').homedir()
7 const arc = require('arc-bookiza')
8 const location = path.join(osHomeDir, '.', '.bookizarc')
9
10 arc.read(location)
11 .then((data) => {
12 const bookizArc = JSON.parse(data) // Arc object
13
14 if (bookizArc.username !== '') {
15 process.stdout.write(chalk.magenta(`${bookizArc.username}`) + chalk.gray(` <${bookizArc.email}>`) + chalk.yellow(`(https://bubblin.io/${bookizArc.username})`) + '\n')
16 return true
17 } else {
18 console.error(chalk.red('Unregistered client. Try $ bookiza register'))
19 return false
20 }
21 }).catch((err) => {
22 if (err) { return console.log('Couldn\'t read bookizarc values', err) }
23 })
24}
25
26module.exports.print = print