Skip to content

Commit 3843e40

Browse files
committed
fix(tsfmt): remove trailing white chars and add linefeed
1 parent 07c7eac commit 3843e40

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ export function processStream(fileName: string, input: NodeJS.ReadableStream, op
7777
});
7878

7979
input.on("end", () => {
80-
if (fragment.slice(-1) === "\n") {
81-
fragment = fragment.slice(0, -1);
82-
}
8380
resolve(fragment);
8481
});
8582
});
@@ -105,6 +102,11 @@ export function processString(fileName: string, content: string, opts: Options):
105102
.all(optGenPromises)
106103
.then(() => {
107104
var formattedCode = formatter(content, options);
105+
if ((<any>formattedCode).trimRight) {
106+
formattedCode = (<any>formattedCode).trimRight();
107+
formattedCode += "\n";
108+
}
109+
108110
// TODO replace newline code. NewLineCharacter params affect to only "new" newline. maybe.
109111
var message: string;
110112
var error = false;

test/indexSpec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe("tsfmt test", () => {
170170
.then(result=> {
171171
assert(result !== null);
172172
assert(result.error === false);
173-
assert(result.dest === `class Sample { getString(): string { return "hi!"; } }`);
173+
assert(result.dest === "class Sample { getString(): string { return \"hi!\"; } }\n");
174174
});
175175
});
176176
});

0 commit comments

Comments
 (0)