mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
fix(nuxi): show base url in terminal (#5337)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
This commit is contained in:
parent
01700002d8
commit
100dfa6653
@ -34,6 +34,7 @@ export default defineNuxtCommand({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const listener = await listen(serverHandler, {
|
const listener = await listen(serverHandler, {
|
||||||
|
showURL: false,
|
||||||
clipboard: args.clipboard,
|
clipboard: args.clipboard,
|
||||||
open: args.open || args.o,
|
open: args.open || args.o,
|
||||||
port: args.port || args.p || process.env.NUXT_PORT,
|
port: args.port || args.p || process.env.NUXT_PORT,
|
||||||
@ -50,6 +51,12 @@ export default defineNuxtCommand({
|
|||||||
const { loadNuxt, buildNuxt } = await loadKit(rootDir)
|
const { loadNuxt, buildNuxt } = await loadKit(rootDir)
|
||||||
|
|
||||||
let currentNuxt: Nuxt
|
let currentNuxt: Nuxt
|
||||||
|
const showURL = () => {
|
||||||
|
listener.showURL({
|
||||||
|
// TODO: Normalize URL with trailing slash within schema
|
||||||
|
baseURL: withTrailingSlash(currentNuxt?.options.app.baseURL) || '/'
|
||||||
|
})
|
||||||
|
}
|
||||||
const load = async (isRestart: boolean, reason?: string) => {
|
const load = async (isRestart: boolean, reason?: string) => {
|
||||||
try {
|
try {
|
||||||
loadingMessage = `${reason ? reason + '. ' : ''}${isRestart ? 'Restarting' : 'Starting'} nuxt...`
|
loadingMessage = `${reason ? reason + '. ' : ''}${isRestart ? 'Restarting' : 'Starting'} nuxt...`
|
||||||
@ -61,6 +68,10 @@ export default defineNuxtCommand({
|
|||||||
await currentNuxt.close()
|
await currentNuxt.close()
|
||||||
}
|
}
|
||||||
currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false })
|
currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false })
|
||||||
|
if (!isRestart) {
|
||||||
|
showURL()
|
||||||
|
}
|
||||||
|
|
||||||
await currentNuxt.ready()
|
await currentNuxt.ready()
|
||||||
await currentNuxt.hooks.callHook('listen', listener.server, listener)
|
await currentNuxt.hooks.callHook('listen', listener.server, listener)
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@ -70,7 +81,7 @@ export default defineNuxtCommand({
|
|||||||
currentHandler = currentNuxt.server.app
|
currentHandler = currentNuxt.server.app
|
||||||
if (isRestart && args.clear !== false) {
|
if (isRestart && args.clear !== false) {
|
||||||
showBanner()
|
showBanner()
|
||||||
listener.showURL()
|
showURL()
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
consola.error(`Cannot ${isRestart ? 'restart' : 'start'} nuxt: `, err)
|
consola.error(`Cannot ${isRestart ? 'restart' : 'start'} nuxt: `, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user