diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-03-10 08:20:03 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-03-10 08:20:03 -0300 |
commit | 684ab7b1fdbb0f56fc15460eb6308b028723a727 (patch) | |
tree | b53893bcfae2a3facf8f473aea079bb7fd4c12c4 /src | |
parent | 7162eb0806563deb8c29df4b11c795ee1771c493 (diff) |
write: live-dev-server: display more relevant addresses preview
Diffstat (limited to 'src')
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index cd84dcc0..ecb9df21 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -1,6 +1,7 @@ import {spawn} from 'node:child_process'; import * as http from 'node:http'; import {open, stat} from 'node:fs/promises'; +import * as os from 'node:os'; import * as path from 'node:path'; import {pipeline} from 'node:stream/promises'; import {inspect as nodeInspect} from 'node:util'; @@ -492,7 +493,13 @@ export async function go({ } }); - const address = `http://${host}:${port}/`; + const addresses = + (host === '0.0.0.0' + ? [`http://localhost:${port}/`, + `http://${os.hostname()}:${port}/`] + : host === '127.0.0.1' + ? [`http://localhost:${port}/`] + : [`http://${host}:${port}/`]); server.on('error', error => { if (error.code === 'EADDRINUSE') { @@ -509,7 +516,15 @@ export async function go({ }); server.on('listening', () => { - logInfo`${'All done!'} Listening at: ${address}`; + if (addresses.length === 1) { + logInfo`${'All done!'} Listening at: ${addresses[0]}`; + } else { + logInfo`${`All done!`} Listening at:`; + for (const address of addresses) { + logInfo`- ${address}`; + } + } + logInfo`Press ^C here (control+C) to stop the server and exit.`; if (showTimings && loudResponses) { logInfo`Printing all HTTP responses, plus page generation timings.`; |