expressjs / expressjs/generator
Modernize generated .gitignore to cover environment-specific dotenv files
- Dominant language
- JavaScript
- Stars
- 1.9k
- Forks
- 548
- PR merge metrics
- No merged PRs in 30d
Description
## Description
The `.gitignore` generated by `express-generator --git` currently ignores `.env`, but does not ignore environment-specific dotenv files such as `.env.local`, `.env.development`, or `.env.production`.
For example, the current template contains:
```gitignore
# dotenv environment variables file
.env
```
I propose updating this to:
```gitignore
# dotenv environment variable files
.env
.env.*
!.env.example
```
This would help protect environment-specific configuration files that may contain credentials or other sensitive values, while still allowing projects to commit a safe `.env.example` file.
## Why?
Node.js applications commonly use multiple dotenv files for different environments, for example:
* `.env`
* `.env.local`
* `.env.development`
* `.env.production`
* `.env.test`
Ignoring only `.env` does not cover these additional `.env.*` files.
The proposed pattern follows a commonly used approach in modern Node.js project templates.
## Proposed change
Update the JavaScript `.gitignore` template in:
`templates/js/gitignore`
from:
```gitignore
# dotenv environment variables file
.env
```
to:
```gitignore
# dotenv environment variable files
.env
.env.*
!.env.example
```
I would also be happy to add or update the relevant tests if this change is accepted.
Would this be a change the maintainers would be open to?
Contributor guide
Assessment
This issue has not been assessed yet.