[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [Feedback](/c/feedback/8) # Always that run the command `vercel env pull` is adding an extra rule `.env*local` to `.gitignore`! 156 views · 6 likes · 5 posts codermarcos (@codermarcos) · 2024-10-26 # 📝 Description This is not a critical bug but is little boring have to remove this extra rule always that I added a new rule to vercel. ## 🔎 Details * CLI Version: **37.12.1** * OS: **Microsoft Windows 11 Pro** ## 📷 Evidence  ## 🐾 Steps to reproduce the issue 1. Using an OS that has end-of-line `crlf` by default like Windows 2. Run `vercel env pull` Into a project that already has a the vercel rules into the `.gitignore` #### 🧪 What's the expected result? Only add the rule `.env*.local` when the `.gitignore` does not have it. #### ❌ What's the actual result? Is adding the same rule multiple times. #### 🫚 Root cause This is happeing because [this condition](https://github.com/vercel/vercel/blob/main/packages/cli/src/util/link/add-to-gitignore.ts#L13) in this file `packages/cli/src/util/link/add-to-gitignore.ts` this is the code: ```ts const EOL = gitIgnore.includes('\r\n') ? '\r\n' : os.EOL; // .. if (!gitIgnore.split(EOL).includes(ignore)) { /* add the rule */ ``` In some cases this condition can be translated to: ```ts const EOL = gitIgnore.includes('\r\n') ? '\r\n' : '\r\n'; ``` For example in my case my file is using `lf` = `\n` but my os use `crlf` = `\r\n` by default that is this condition will never be `true`. ### ✅ Solution I did a few changes in this code that I would like to check first here to avoid a forgotten PR! #### Changes 1. Move this file `add-to-gitignore.ts` from `src/util/link` to `src/util` since it is not only used in **link** command but also in **env** command. 2. Change the code to check as an string. It is good for two reasons: - The `.gitignore` can have multiples rules at the same line - Doesn't matter what is the end-of-line ```ts if (gitIgnore.includes(ignore)) return isGitIgnoreUpdated; ``` 3. The last change that I would like to check if it is ok 🤔 or is too much. I created a function to get the dominant end-of-line and use it when add a new line. This is the code: ```ts function getDominantEOL(text: string) { const lines = (text.match(/\r\n|\n/g) ?? []) as Array<'\r\n' | '\n'>; const { '\n': LFCount, '\r\n': CRLFCount, } = lines.reduce( (counter, lineEnding) => { counter[lineEnding] += 1; return counter; }, { '\n': 0, '\r\n': 0 }, ); const dominantEOL = LFCount > CRLFCount ? '\n' : '\r\n'; return LFCount === CRLFCount ? os.EOL : dominantEOL; } ``` It can be simpler checking if there is any kind of end-of-line otherwise it uses the os end-of-line: ```ts function getEOL(text: string) { if (text.includes('\r\n')) return '\r\n'; if (text.includes('\n')) return '\n'; return os.EOL; } ``` I will open the PR soon and leave the link to it here! If you have any suggestions I will be happy to apply it 😊 Swarnava Sengupta (@swarnava) · 2024-10-27 · ♥ 1 Hey! Thank you for taking the time to write to us with such in-depth detail. We greatly appreciate your feedback and ideas. I have forwarded your message to the appropriate team for them to adequately address. In the meantime, I would highly suggest creating a Pull request. This way, our team can thoroughly review your suggestions and work on implementing them if deemed appropriate. We always welcome feedback from our community and we're more than happy to review any contributions. Thank you! codermarcos (@codermarcos) · 2024-10-27 · ♥ 3 @swarnava Thank you, for your so fast anwser 💘! I [created it here](https://github.com/vercel/vercel/pull/12396) Swarnava Sengupta (@swarnava) · 2024-10-27 · ♥ 1 I have forwarded your PR as well internally. Feel free to give me a nudge if you don't hear back from us soon. Thank you for your help! Pauline P. Narvas (@pawlean) · 2024-10-28 · ♥ 1 Thanks for your contribution, @codermarcos! :smile: