replit / upm

⠕ Universal Package Manager - Python, Node.js, Ruby, Emacs Lisp.
https://repl.it
Other
1.05k stars 89 forks source link

Ensure that we handle the optionality of the trailing newline in requirements.txt #237

Closed blast-hardcheese closed 6 months ago

blast-hardcheese commented 6 months ago

Why

The requirements.txt handling during upm add did no checking to see whether the file had a newline or not before adding one. This would lead to situations where attempting to upm add dep2 to a file that already contained dep1 would result in dep1dep2.

What changed

Determine whether the file already has a newline. If it does, maintain that newline as we add new lines to the file. If it doesn't, maintain its absence.

Test plan

echo -n pytest > requirements.txt
upm add flask

Prior to this change, you'd end up with pytestFlask\n. After this change, we will end up with pytest\nFlask

blast-hardcheese commented 6 months ago

We hardcode \n everywhere today, supporting Windows will require significant effort, this change doesn't preclude that in the future, so I'm gonna proceed.