82

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?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Quan Vuong
  • 1,919
  • 3
  • 14
  • 24

3 Answers3

220

You can use firebase partial deploys

$ firebase deploy --only functions:makeUppercase

Will only deploy makeUppercase function.

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

$ firebase deploy --only functions:function1,functions:function2
starball
  • 20,030
  • 7
  • 43
  • 238
Pablo Albaladejo
  • 2,950
  • 1
  • 17
  • 21
16

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks Frank. You have helped me out more than once :) – Quan Vuong Mar 12 '17 at 19:10
  • feature request filed. Thanks for the link! – Quan Vuong Mar 12 '17 at 19:12
  • 1
    I could use some help with this! I would like to deploy multiple functions as well. I have set up my project structure exactly like https://github.com/firebase/functions-samples has. In fact, I used it as a base, stripped all but two functions, modified, and want to deploy. I have tried firebase deploy, firebase deploy --only ..., and comma separated attempts. – Quinn Turner Mar 23 '17 at 20:59
  • If I run "firebase deploy" from root I get that it couldn't locate firebase.json. My guess is I have to restructure the applications, but I haven't had any luck after trying a few alternatives. – Quinn Turner Mar 23 '17 at 21:04
  • @QuinnTurner Try running `firebase init`, which will add all necessary files. – Scott Apr 13 '17 at 23:53
  • @QuinnTurner please don't post new questions in a comment. If you have a new problem, post a new question. Be sure to include the [minimal code that reproduces the problem](http://stackoverflow.com/help/mcve) in that question (and read the link, it's quite useful). – Frank van Puffelen Apr 14 '17 at 06:32
1

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...

Jonathan
  • 3,893
  • 5
  • 46
  • 77