fix: respect current EOL in gitignore #329
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #301
Problem:
sf-install
reads the.gitignore
in the project and tries to split the content by\n
(even on windows).This messes up your gitignore if it uses
CRLF
(most common on windows but can happen on linux/mac too) like in the linked issue above.dev-scripts now will detect the EOL used by the local file and use that for parsing the content and final write.
We can't use node's
os.EOL
because it assumes unix ===LF
and win ===CRLF
.same change in
sf-clean
NOTE:
there's a file check done here to see if the
.gitignore
in the project matches the template:dev-scripts/utils/standardize-files.js
Line 79 in e2efc93
https://github.com/forcedotcom/dev-scripts/blob/e2efc93a4af12dc5953d1beb673cc768a7e620a6/utils/standardize-files.js#L35C1-L48C2
isDifferent
just normalizes line endings for comparision so that's left as is.Testing
plugin-info
(or any other of our plugins).gitignore
use CRLF (open in vscode click onLF
at the bottom of the screen, chooseCRLF
and save the filesf-install
now run
yarn
(will runsf-install
), it'll printstandardizing config files for plugin-info
and if you open the file you'll see it's missing theCLEAN ALL
items and other stuff.sf-clean
restore changes (clean git status), redo step 1 & 2 and run
yarn clean
, will print:but the gitignore have more stuff in it that's missing because of
CRLF
.install the prerelease in this branch and the steps above should work wether gitignore uses
LF
orCRLF
on any os.@W-15748612@