cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.46k stars 160 forks source link

Generated files have mixed line ending on windows #414

Open ADegele opened 6 years ago

ADegele commented 6 years ago

When generating TS files on windows, jsweet produces files with both Linux and Windows line endings. I've escaped the line endings in the following file:

/* Generated from Java with JSweet 2.1.0-SNAPSHOT - http://www.jsweet.org */\r\n
import { IReferenzwertDBE } from '../../referenzwerte/data/interfaces/IReferenzwertDBE';\n
\n
export class PartnerBeziehungDBE {\n
    constructor() {\n
    }\n
}\n
PartnerBeziehungDBE["__class"] = "project.partner.data.PartnerBeziehungDBE";\n
PartnerBeziehungDBE["__interfaces"] = [lots of interfaces];\n
\n
\n
\n
\r\n

The first and last line has Windows line endings, while the others have Linux line endings. On a Linux machine, all line endings are Linux, which causes whitespace diffs. We fixed it with postprocessing the files, since we have a special configuration for git, but you should be aware of it.

renaudpawlak commented 6 years ago

Thank you for notifying. In theory generated files should not be in Git, but I guess it may depend on your use case. I guess that the best way deal with this issue would be to force the line endings style with a transpiler option... Or simply to force Unix style all the time :)

ADegele commented 6 years ago

Well, we had a lengthy discussion in the team whether we should check in generated files. We decided for it, because it makes changes in the generators visible. Apart from that, it is easier in our multi-step build. I think the best way would be to have per default either system dependent or Unix style all the time, with a transpiler option to overwrite that behavior.

lgrignon commented 6 years ago

+1 for Unix style all the time