Skip to content

Commit

Permalink
fix: use terminal-banner
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jan 17, 2018
1 parent 6f5a598 commit a6e2c14
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 32 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ describe('no banner', () => {
})
```

Uses [terminal-banner](https://github.com/bahmutov/terminal-banner) under the hood.

### Small print

Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2018
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"standard": "10.0.3"
},
"dependencies": {
"its-name": "1.0.0"
"its-name": "1.0.0",
"terminal-banner": "1.0.0"
}
}
33 changes: 2 additions & 31 deletions src/banner.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
const defaultWidth = 40
const terminalWidth = () =>
(process.stdout.isTTY ? process.stdout.columns : defaultWidth) || defaultWidth
import { terminalBanner } from 'terminal-banner'

const horizontalLine = (symbol?: string) => {
symbol = symbol || '-'
const n = terminalWidth()
var k
var str = ''
for (k = 0; k < n; k += 1) {
str += symbol
}
return () => {
console.log(str)
}
}

const centerText = (text: string): string => {
const w = terminalWidth()
let s = text
while (s.length < w - 1) {
s = ' ' + s + ' '
}
return s
}

export default (text: string, symbol?: string) => {
const hr = horizontalLine(symbol)
hr()
console.log(centerText(text))
hr()
}
export default terminalBanner

0 comments on commit a6e2c14

Please sign in to comment.