Newline detection in addToGitIgnore

We’ve run into an issue when running vercel env pull where .env*.local is added to .gitgnore even when it’s already in the file.

The problem seems to be in addToGitIgnore here where the EOL is determined.

In my case, I’m working on Windows (where os.EOL is \r\n) but our .gitignore has \n line-endings. So, the line referenced above does not successfully split the .gitignore file lines and, thus, when the check is performed to see if .env*.local (or whatever is passed in) is already in the file, it fails and adds it again.

The solution seems to simply use \n in the else of the ternary on line 13. Like this: Comparing vercel:main...benramey-faithlife:fix-newline-detection-in-addToGitIgnore · vercel/vercel · GitHub

1 Like

Looks like there is a pull request attempting to address this issue. I feel like the solution proposed in that PR is overly complex, but perhaps it’s addressing potential edge cases I’m not thinking of.