Skip to content

Commit cf9379f

Browse files
authored
BREAKING: Ignore 'functions' directory in a Firebase project without a functions config in firebase.json (#6555)
Historically, Firebase CLI reserved directory named `functions` inside a Firebase project directory for use by Cloud Functions for Firebase. This meant that if `functions` directory exists, it was assumed to hold CF3 source code. However, we recognize that there are valid use case for using `functions` directory name, especially in monorepo-like setups. With this change, Firebase CLI will only reserve `functions` directory when there is a `functions` configuration entry in firebase.json that does not specify the `source` directory. This change will be released in the next breaking change of the Firebase CLI (v13). Fixes #6450
1 parent f66b65e commit cf9379f

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"functions": {}
3+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"functions": {}
3+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"functions": {}
3+
}

src/config.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,17 @@ export class Config {
7676
}
7777
});
7878

79-
// Inject default functions config and source if missing.
80-
if (this.projectDir && fsutils.dirExistsSync(this.path(Config.DEFAULT_FUNCTIONS_SOURCE))) {
81-
if (Array.isArray(this.get("functions"))) {
82-
if (!this.get("functions.[0].source")) {
83-
this.set("functions.[0].source", Config.DEFAULT_FUNCTIONS_SOURCE);
84-
}
85-
} else {
86-
if (!this.get("functions.source")) {
87-
this.set("functions.source", Config.DEFAULT_FUNCTIONS_SOURCE);
79+
// Inject default functions source if missing.
80+
if (this.get("functions")) {
81+
if (this.projectDir && fsutils.dirExistsSync(this.path(Config.DEFAULT_FUNCTIONS_SOURCE))) {
82+
if (Array.isArray(this.get("functions"))) {
83+
if (!this.get("functions.[0].source")) {
84+
this.set("functions.[0].source", Config.DEFAULT_FUNCTIONS_SOURCE);
85+
}
86+
} else {
87+
if (!this.get("functions.source")) {
88+
this.set("functions.source", Config.DEFAULT_FUNCTIONS_SOURCE);
89+
}
8890
}
8991
}
9092
}

0 commit comments

Comments
 (0)