如何使用 Firebase Cloud Functions 检测环境是开发环境还是生产环境? [英] How to detect if environment is development or production with Firebase Cloud Functions?

查看:20
本文介绍了如何使用 Firebase Cloud Functions 检测环境是开发环境还是生产环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How can I detect if my server environment is development or production with Firebase Cloud Functions?

I need something like this:

if(process.env.NODE_ENV === 'development'){

   //DO STUFF SPECIFIC TO DEV ENVIRONMENT

}
else if(process.env.NODE_ENV === 'production'){

   //DO STUFF SPECIFIC TO PRODUCTION ENVIRONMENT

}

解决方案

process.env.FUNCTIONS_EMULATOR

At process.env, on firebase functions projects, there is a boolean variable called FUNCTIONS_EMULATOR, which indicates if the process is running on an emulator or on server.

this is enough to determine if environment is dev or production.

process.env.FUNCTIONS_EMULATOR === true

Obs: In some environments the variable might be a String 'true' instead of Boolean true

这篇关于如何使用 Firebase Cloud Functions 检测环境是开发环境还是生产环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆