Skip to content

Commit

Permalink
BREAKING: Ignore 'functions' directory in a Firebase project without …
Browse files Browse the repository at this point in the history
…a functions config in firebase.json

Don't assume all directory named `functions` are functions directory. Instead, expect developers to explicitly set up a "functions" config in their firebase.json.
  • Loading branch information
taeold committed Nov 28, 2023
1 parent dbedf74 commit 0838879
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 3 additions & 1 deletion scripts/functions-discover-tests/fixtures/esm/firebase.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"functions": {}
}
4 changes: 3 additions & 1 deletion scripts/functions-discover-tests/fixtures/pnpm/firebase.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"functions": {}
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"functions": {}
}
20 changes: 11 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@ export class Config {
}
});

// Inject default functions config and source if missing.
if (this.projectDir && fsutils.dirExistsSync(this.path(Config.DEFAULT_FUNCTIONS_SOURCE))) {
if (Array.isArray(this.get("functions"))) {
if (!this.get("functions.[0].source")) {
this.set("functions.[0].source", Config.DEFAULT_FUNCTIONS_SOURCE);
}
} else {
if (!this.get("functions.source")) {
this.set("functions.source", Config.DEFAULT_FUNCTIONS_SOURCE);
// Inject default functions source if missing.
if (this.get("functions")) {
if (this.projectDir && fsutils.dirExistsSync(this.path(Config.DEFAULT_FUNCTIONS_SOURCE))) {
if (Array.isArray(this.get("functions"))) {
if (!this.get("functions.[0].source")) {
this.set("functions.[0].source", Config.DEFAULT_FUNCTIONS_SOURCE);
}
} else {
if (!this.get("functions.source")) {
this.set("functions.source", Config.DEFAULT_FUNCTIONS_SOURCE);
}
}
}
}
Expand Down

0 comments on commit 0838879

Please sign in to comment.