facebook / facebook/jscodeshift
toSource() outputs CRLF newline when input file only had LF
Offen
bug
- Vorherrschende Sprache
- JavaScript
- Sterne
- 10k
- Forks
- 498
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
The README claims that it will do its best to preserve whitespace/formatting. But instead it adds CRLF when I wasn’t expecting it. It looks like I can work around it by doing something like:
```javascript
module.exports = function (fileInfo, {
jscodeshift,
}, options) {
const isUnix = fileInfo.source.indexOf('\r\n') === -1;
const dom = jscodeshift(fileInfo.source);
return dom.toSource().replace(/\r\n/g, isUnix ? '\n' : '\r\n');
};
```
However, that behavior should probably just be provided out of the box instead of requiring this hack.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.