/
index.js
executable file
·70 lines (59 loc) · 1.31 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env node
const { inspect } = require('util')
const id = (a) => a
const isTty = process.stdout.isTTY
const cols = (color, text) => {
const codes = inspect.colors[color]
return `\x1b[${codes[0]}m${text}\x1b[${codes[1]}m`
}
const colorize = () => {
const val = {}
Object.keys(inspect.colors).forEach((color) => {
val[color] = (text) => cols(color, text)
})
return val
}
const colors = isTty
? colorize()
: Object.keys(inspect.colors).reduce((prev, curr) => {
prev[curr] = id
return prev
}, {})
const indent = isTty ? ' ' : ''
const zac = {
Name: 'Zac Anger',
Title: 'Senior Software Engineer',
Web: 'https://zacanger.com',
Resume: 'https://zacanger.com/resume',
GitHub: 'https://github.com/zacanger'
}
const divider = '-'.repeat(42)
const { bold, green, blue, yellow } = colors
const infoString = `
${bold(blue(divider))}
${green(zac.Name)}
${green(zac.Title)}
${blue(divider)}
${Object.keys(zac)
.reduce(
(p, c) =>
['Name', 'Title'].includes(c)
? p + ''
: p + `${bold(c)}: ${yellow(zac[c])}\n`,
''
)
.trim()}
${bold(blue(divider))}
`
.trim()
.split('\n')
.reduce((p, c) => p + `${indent}${c}\n`, '')
.trimEnd()
const main = () => {
console.log(infoString)
}
if (require.main === module) {
main()
} else {
module.exports = zac
}