firebase / firebase/firebase-tools

firebase.json: functions.ignore not including deeper directories

Open
#8,131 2 comments 0 reactions 0 assignees View on GitHub
api: functions reproducible type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** `13.29.1`

**Platform:** `macOS`

### [REQUIRED] Test case

See simple setup here https://github.com/rhodgkins/firebase-tools-functions-ignore

I have a directory named `deployment` at the root inside the `functions.source` directory, and also another directory `deployment` in the `foobar` directory at the root. I want the root `deployment` directory to not be uploaded with the functions.

- `functions/`
- `deployment/` - ignore this whole directory
- `foobar/`
- `deployment/` - want this directory (and everything inside it) included

### [REQUIRED] Steps to reproduce

Deploy the functions:

`firebase --project=XXX deploy --only=functions`

Found this due to having a deployment directory (with some config files not related to the function runtime execution) and another sub directory called deployment which was named after some function functionality. Couldn't work out why the directory wasn't being uploaded.
I've tried using `deployment/*` in the `ignore` instead but then the root `deployment` directory gets uploaded.

I think it's mainly due to how paths are filtered here:
https://github.com/firebase/firebase-tools/blob/e145360f2d47f50be21d167d50ddf6f124a54ac4/src/fsAsync.ts#L23

It shouldn't include base `sourceDir` and then the `minimatch` filters will work correctly with `deployment/*`.

Going to attempt a fix, or at least start off with a PR with a failing test case for `readdirRecursive`

### [REQUIRED] Expected behavior

For `functions/foobar/deployment` directory to be uploaded, but `functions/deployment` to not be included.

### [REQUIRED] Actual behavior

`functions/foobar/deployment` and everything in it, is excluded.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.