microsoft / vscode-l10n

MIT License
63 stars 12 forks source link

Line ending when call @vscode/l10n-dev export #129

Open Cosifne opened 1 year ago

Cosifne commented 1 year ago

Hi,

We have seen in https://github.com/dotnet/vscode-csharp/blob/main/l10n/bundle.l10n.json, initially everything is end with crlf But after adding a string and run @vscode/l10n-dev export git would complain that the line ending is changed to lf

image

Is there any way to use 'crlf' as the line ending?

TylerLeonhardt commented 1 year ago

I'm using JSON.stringify to turn the bundle object into a string: https://github.com/microsoft/vscode-l10n/blob/main/l10n-dev/src/cli.ts#L181

it turns out there isn't a way to say "I want the lines to end in CRLF" within JSON.stringify... so the only solution is to do something prettty hacky by post processing. We run the risk of turning actual expected usages of LF's into CLRF's which does concern me.

Alternatives:

Configuring git to allow LF files would workaround this warning: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings

The other question I have is... why check in a file that's entirely generated?

Cosifne commented 1 year ago

Hi Tyler, We run all the localization work in the pipeline so every time the bot performed localization, someone in our team would see this issue. So I start the issue to ask if there is any existing solution for this.

It's not a big problem if it is not configurable now. Thanks for your quick response.

FALLAI-Denis commented 10 months ago

Hi,

What if add replace("\r(\n)?","\r\n") on result string of JSON.stringify?

writeFileSync(resolvedOutFile, JSON.stringify(jsonResult, undefined, 2).replace("\r(\n)?","\r\n"))