firebase deploy --only functions overrides existing functions

FunctionFirebaseFirebase ToolsGoogle Cloud-Functions

Function Problem Overview


Running firebase deploy --only functions deletes the existing functions before creating new ones. Is it possible to modify this behavior to create if not exist, update if exists, no actions if functions not being deployed?

Function Solutions


Solution 1 - Function

You can use firebase partial deploys

$ firebase deploy --only functions:makeUppercase

Will only deploy makeUppercase function.

Hope it helps.

Note: To deploy more than one function at once (but not all) use:

$ firebase deploy --only functions:function1,functions:function2

Solution 2 - Function

firebaser here

Running firebase deploy will deploy all functions in the project. There is currently no option to deploy just new or modified functions.

It does sound like a useful addition though, so you might want to file a feature request.

Update: since version 3.8 of the Firebase tools CLI this is possible. See Pablo's answer or the release notes.

Solution 3 - Function

Make sure you are editing the functions in your "functions/src" directory and not the functions in your 'lib' directory. I made this mistake and watched them get replaced...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionQuan VuongView Question on Stackoverflow
Solution 1 - FunctionPablo AlbaladejoView Answer on Stackoverflow
Solution 2 - FunctionFrank van PuffelenView Answer on Stackoverflow
Solution 3 - FunctionJonathanView Answer on Stackoverflow