Skip to content

Commit

Permalink
fix: add \n to surrounding of listen message
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 5, 2021
1 parent e735293 commit b4b1300
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/index.ts
Expand Up @@ -106,16 +106,14 @@ 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
lines.push(` > Local: ${formatURL(url)} ${add}`)
if (isExternal) {
for (const ip of getExternalIps()) {
// eslint-disable-next-line no-console
lines.push(` > Network: ${formatURL(url.replace('localhost', ip))}`)
}
}
// eslint-disable-next-line no-console
console.log(lines.join('\n') + '\n')
console.log('\n' + 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(expect.stringMatching('> Local: http://localhost:3000/foo/bar'))
// expect(console.log).toHaveBeenCalledWith(expect.stringMatching('\n > Local: http://localhost:3000/foo/bar'))
})

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

0 comments on commit b4b1300

Please sign in to comment.