@@ -146,15 +146,25 @@ interface EmulatorStatuses {
146
146
}
147
147
const emulatorStatus : EmulatorStatuses = { } ;
148
148
149
+ interface EmulatorSummary {
150
+ prod : string [ ] ;
151
+ emulator : string [ ] ;
152
+ }
153
+
149
154
// 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
+ } ;
152
160
for ( const key of Object . keys ( emulatorStatus ) ) {
153
161
if ( emulatorStatus [ key ] ) {
154
- runningEmulator = true ;
162
+ summary . emulator . push ( key ) ;
163
+ } else {
164
+ summary . prod . push ( key ) ;
155
165
}
156
166
}
157
- return runningEmulator ;
167
+ return summary ;
158
168
}
159
169
160
170
function getOrCreateEl ( id : string ) : { created : boolean ; element : HTMLElement } {
@@ -188,10 +198,8 @@ export function updateEmulatorBanner(
188
198
189
199
emulatorStatus [ name ] = isRunningEmulator ;
190
200
const bannerId = '__firebase__banner' ;
191
- if ( ! areRunningEmulator ( ) ) {
192
- tearDown ( ) ;
193
- return ;
194
- }
201
+ const summary = getEmulatorSummary ( ) ;
202
+ const showError = summary . prod . length > 0 ;
195
203
196
204
function tearDown ( ) : void {
197
205
const element = document . getElementById ( bannerId ) ;
@@ -225,10 +233,17 @@ export function updateEmulatorBanner(
225
233
} ;
226
234
bannerEl . appendChild ( firebaseText ) ;
227
235
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' ;
229
245
}
230
246
firebaseText . setAttribute ( 'id' , '__firebase__text' ) ;
231
- firebaseText . innerText = 'Running in this workspace' ;
232
247
}
233
248
if ( document . readyState === 'loading' ) {
234
249
window . addEventListener ( 'DOMContentLoaded' , setupDom ) ;
0 commit comments