Skip to content

Commit

Permalink
fix: add empty line to listening message
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 5, 2021
1 parent 60e15bc commit 8381c49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/index.ts
Expand Up @@ -105,14 +105,17 @@ export async function listen (handle: http.RequestListener, opts: Partial<Listen

if (opts.showURL) {
const add = opts.clipboard ? gray('(copied to clipboard)') : ''
const lines = []
// eslint-disable-next-line no-console
console.log(` > Local: ${formatURL(url)} ${add}`)
lines.push(` > Local: ${formatURL(url)} ${add}`)
if (isExternal) {
for (const ip of getExternalIps()) {
// eslint-disable-next-line no-console
console.log(` > Network: ${formatURL(url.replace('localhost', ip))}`)
lines.push(` > Network: ${formatURL(url.replace('localhost', ip))}`)
}
}
// eslint-disable-next-line no-console
console.log(lines.join('\n') + '\n')
}

const _open = async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Expand Up @@ -44,7 +44,7 @@ describe('listhen', () => {
expect(listener.url.startsWith('http://')).toBe(true)
expect(listener.url.endsWith('/foo/bar')).toBe(true)
// eslint-disable-next-line no-console
expect(console.log).toHaveBeenCalledWith(' > Local: http://localhost:3000/foo/bar (copied to clipboard)')
expect(console.log).toHaveBeenCalledWith(expect.stringMatching('> Local: http://localhost:3000/foo/bar'))
})

test('listen (https - selfsigned)', async () => {
Expand Down

0 comments on commit 8381c49

Please sign in to comment.