Is there a way to deploy functions to different firebase projects listed inside .firebaserc
with a single command?
I have this sample .firebaserc
{
"projects": {
"default": "project1",
"project2": "project2-abcd"
}
}
When updating functions, I do:
firebase use default && firebase deploy && firebase use project2 && firebase deploy
If I have tons of projects, the command gets longer so I made a node script that automates deploying to all projects listed in .firebaserc
:
const { promisify } = require("util");
const exec = promisify(require("child_process").exec);
const readFile = promisify(require("fs").readFile);
const deploy = async () => {
try {
const data = await readFile("./.firebaserc", "utf-8");
const projects = Object.keys(JSON.parse(data).projects);
for (const proj of projects) {
console.log(`Deploying functions to ${proj}...`);
const { stdout, stderr } = await exec(
`firebase use ${proj} && firebase deploy`
);
console.log("stdout:", stdout);
console.log("stderr:", stderr);
}
} catch (e) {
console.log(e);
}
};
deploy();
which works but I'm trying to look for an alternative if there is one.