Skip to content

Commit 8d84ddb

Browse files
committed
fix(tsfmt): replace line delimiter to formatOptions.NewLineCharacter fixes #26
1 parent ae3369f commit 8d84ddb

File tree

14 files changed

+824
-825
lines changed

14 files changed

+824
-825
lines changed

lib/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,16 @@ export function processString(fileName: string, content: string, opts: Options):
107107
let formattedCode = formatter(fileName, content, formatOptions);
108108
if ((<any>formattedCode).trimRight) {
109109
formattedCode = (<any>formattedCode).trimRight();
110-
formattedCode += "\n";
110+
formattedCode += formatOptions.NewLineCharacter;
111111
}
112112

113113
postProcesses.forEach(postProcess => {
114114
formattedCode = postProcess(fileName, formattedCode, opts, formatOptions) || formattedCode;
115115
});
116116

117-
// TODO replace newline code. NewLineCharacter params affect to only "new" newline. maybe.
117+
// replace newline code. maybe NewLineCharacter params affect to only "new" newline by language service.
118+
formattedCode = formattedCode.replace(/\r?\n/g, formatOptions.NewLineCharacter);
119+
118120
let message: string;
119121
let error = false;
120122
if (opts && opts.verify) {

0 commit comments

Comments
 (0)