BrowserSync / browser-sync

Keep multiple browsers & devices in sync when building websites. https://browsersync.io
https://discord.gg/2d2xUThp
Apache License 2.0
12.17k stars 754 forks source link

How to call init banner programmatically? #1701

Open Grawl opened 5 years ago

Grawl commented 5 years ago

Issue details

When Browsersync starts, it shows this banner to command line:

[BrowserSync] Proxying: http://localhost:10623
[BrowserSync] Access URLs:
 --------------------------------------
       Local: http://localhost:30623
    External: http://192.168.1.71:30623
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 --------------------------------------

I want to get it every time when my Gulp watcher is running, to get something like Webpack log.

Is there a way to get it? Or even some Gulp plugin to do something like this?

Steps to reproduce/test case

Start Browsersync and look at command line output

Please specify which version of Browsersync, node and npm you're running

Browsersync use-case

ericmorand commented 11 months ago

I know this question was asked a long time ago, but since I just stumbled into it by looking for the same answer, allow me to answer: there is a non-documented (but exposed by the API and the TypeScript definitions) function available on each BrowserSync instance, named getOption.

You can use it like this to get a Map of all the URLs listened by Browsersync server:

browserSyncInstance.getOption('urls');

From there, you can construct your own banner.