I'm trying to emulate only specific Cloud Functions within my Firebase project. My functions are organized in subfolders within a "functions" directory.
My folder structure looks like this:
functions/
├── firebase.json
├── function-one-folder/
│ └── index.js
├── function-two-folder/
│ └── index.js
└── function-three-folder/
└── index.js
I'm using the firebase emulators:start --only functions:functionName
command, but it seems to start emulators for all functions within the functions directory, regardless of the --only
flag.
Here is an example of what I've tried (to only run the emulator for functionOne
):
firebase emulators:start --only functions:functionOne
Is there a correct way to use the --only functions
flag to specifically emulate functions within subfolders? Or are there alternative approaches to achieve selective function emulation?
The --only
flag for firebase emulators:start
as documented allows you to specify which one product to emulate. The documentation says nothing about selecting anything more specific or narrow than the one product, so what you're trying to do isn't supported. The syntax you're using with --only
is only supported for firebase deploy
.
It isn't clear to me why you must run the emulator for only one function, but if that is what you require, you can simply remove the unwanted function definition exports from your top-level index.js so that they aren't available to the emulator.
You are always free to file an issue on GitHub to request a new feature, though you should probably explain in detail why it's a problem for you to enable all of the functions by default.