facebook / facebook/jscodeshift

toSource() outputs CRLF newline when input file only had LF

Aperta
#262 5 commenti 10 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
JavaScript
Stelle
10k
Fork
498
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.