Skip to content

feat(dev): return listener instance for programmatic usage - #278

Merged
pi0 merged 3 commits into
nuxt:mainfrom
mandarini:feat/expose-baseUrl
Nov 20, 2023
Merged

pi0 merged 3 commits into
nuxt:mainfrom
mandarini:feat/expose-baseUrl

Conversation

@mandarini

Copy link
Copy Markdown
Contributor

When calling await runCommand("dev"); programmatically, I would like to be able to get the baseUrl, the listening URL.

This will also require a change in citty, to return the result, here: https://github.com/unjs/citty/blob/cb27bed49371682904d85421439e31b8b3b17d24/src/command.ts#L64 specifically, to return the result of the run function.

    if (typeof cmd.run === "function") {
      return await cmd.run(context);
    }

@mandarini

Copy link
Copy Markdown
Contributor Author

@pi0 I submitted this PR, it is needed in Nx, to get the baseUrl, and expose it to cypress. It's not urgent or blocking for us, but I thought it would be a nice to have! :)

@pi0

pi0 commented Nov 3, 2023

Copy link
Copy Markdown
Member

Thanks for the citty PR that's a good one! For receiving listener URL(s), you might also use a listen nuxt hook it gives the listener context.

Comment thread src/commands/dev.ts Outdated
// Fork nuxt dev process
const devProxy = await _createDevProxy(nuxtOptions, listenOptions)
await _startSubprocess(devProxy, ctx.rawArgs)
return devProxy?.listener?.url

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as citty, we might return { listener } here too (also notice when using a public URL or domain or tunnel, there are multiple listener URLs as well. url is the prefered one we usually show first and used for public/qr when available)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pi0 I pushed a new commit with the change you requested! Thanks!

@mandarini
mandarini force-pushed the feat/expose-baseUrl branch from afc0d28 to f7ae771 Compare November 6, 2023 08:57
@pi0 pi0 changed the title feat(dev): return listener url feat(dev): return listener instance for programmatic usage Nov 20, 2023
@pi0
pi0 merged commit 80566b2 into nuxt:main Nov 20, 2023
@pi0

pi0 commented Nov 20, 2023

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants