@@ -146,15 +146,25 @@ interface EmulatorStatuses {
146146}
147147const emulatorStatus : EmulatorStatuses = { } ;
148148
149+ interface EmulatorSummary {
150+ prod : string [ ] ;
151+ emulator : string [ ] ;
152+ }
153+
149154// Checks whether any products are running on an emulator
150- function areRunningEmulator ( ) : boolean {
151- let runningEmulator = false ;
155+ function getEmulatorSummary ( ) : EmulatorSummary {
156+ const summary : EmulatorSummary = {
157+ prod : [ ] ,
158+ emulator : [ ]
159+ } ;
152160 for ( const key of Object . keys ( emulatorStatus ) ) {
153161 if ( emulatorStatus [ key ] ) {
154- runningEmulator = true ;
162+ summary . emulator . push ( key ) ;
163+ } else {
164+ summary . prod . push ( key ) ;
155165 }
156166 }
157- return runningEmulator ;
167+ return summary ;
158168}
159169
160170function getOrCreateEl ( id : string ) : { created : boolean ; element : HTMLElement } {
@@ -188,10 +198,8 @@ export function updateEmulatorBanner(
188198
189199 emulatorStatus [ name ] = isRunningEmulator ;
190200 const bannerId = '__firebase__banner' ;
191- if ( ! areRunningEmulator ( ) ) {
192- tearDown ( ) ;
193- return ;
194- }
201+ const summary = getEmulatorSummary ( ) ;
202+ const showError = summary . prod . length > 0 ;
195203
196204 function tearDown ( ) : void {
197205 const element = document . getElementById ( bannerId ) ;
@@ -225,10 +233,17 @@ export function updateEmulatorBanner(
225233 } ;
226234 bannerEl . appendChild ( firebaseText ) ;
227235 bannerEl . appendChild ( closeBtn ) ;
228- document . body . appendChild ( banner . element ) ;
236+ document . body . appendChild ( bannerEl ) ;
237+ }
238+ if ( showError ) {
239+ banner . element . style . background = '#cd5c5c' ;
240+ firebaseText . innerText = `Product${
241+ summary . prod . length > 0 ? 's' : ''
242+ } Running in Production: ${ summary . prod . join ( ', ' ) } `;
243+ } else {
244+ firebaseText . innerText = 'Running in this workspace' ;
229245 }
230246 firebaseText . setAttribute ( 'id' , '__firebase__text' ) ;
231- firebaseText . innerText = 'Running in this workspace' ;
232247 }
233248 if ( document . readyState === 'loading' ) {
234249 window . addEventListener ( 'DOMContentLoaded' , setupDom ) ;
0 commit comments