`npx convex dev` always adds `.env.local` to `.gitignore`?
Hey team!
I'm working on an open source repo that requires contributors to initialize Convex on their local machines. I've noticed a few contributors push code that adds
.env.local
at the bottom of .gitignore
, even though it's already listed above. I think this is being added automatically during the initialization process. Is there a way to disable this, or to improve the .gitignore
pattern matching so it doesn't get added?8 Replies
Weird, it looks like that shouldn't be happening for your case: https://github.com/get-convex/convex-js/blob/84314db1f591306faf2cab9b46a458f6128a7647/src/cli/lib/deployment.ts#L144-L162
GitHub
convex-js/src/cli/lib/deployment.ts at 84314db1f591306faf2cab9b46a4...
TypeScript/JavaScript client library for Convex. Contribute to get-convex/convex-js development by creating an account on GitHub.
Maybe there's some unexpected whitespace getting into the lines array
Are you on windows? I wonder if the split("\n") isn't accounting for the \r in windows line endings
I’m on Mac, but the contributors may have been on Windows, I’m not sure.
Would the check work using
line.includes(“.env.local”)
instead of line === “.env.local”
?
And if so would a PR be welcome?could still give (unlikely) false positives - maybe
str.split(/\r?\n/)
I’m just imagining cases where there’s an extra space after the line, or an inline comment like
.env.local # convex local env variables
startsWith
could be more forgiving than ===
but less than contains
ah good point
Given the failure case is zero impact, your first approach makes sense. Pretty sure they'd take a PR.
I will give it a stab!