Skip to content
Merged
Prev Previous commit
Next Next commit
Compiler flag to specify line ending #1693 code review adjustments
  • Loading branch information
kmashint committed May 3, 2015
commit c1d2aeab84802f5b4235eb4ab2ddfbbab247f23d
2 changes: 1 addition & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module ts {
},
{
name: "newLine",
type: { "crlf": NewLineKind.CRLF, "lf": NewLineKind.LF },
type: { "crlf": NewLineKind.CarriageReturnLineFeed, "lf": NewLineKind.LineFeed },
description: Diagnostics.Emit_newline_Colon_CRLF_dos_or_LF_unix,
paramType: Diagnostics.NEWLINE,
error: Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@
"category": "Message",
"code": 6062
},
"Argument for --newLine option must be 'CRLF' or 'LF'.": {
"Argument for 'newLine' option must be 'CRLF' or 'LF'.": {
"category": "Error",
"code": 6063
},
Expand Down
7 changes: 5 additions & 2 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ module ts {
}
}

let newLine = [sys.newLine, "\r\n", "\n"][options.newLine ? Number(options.newLine) : 0];

let newLine =
options.newLine === NewLineKind.CarriageReturnLineFeed ? "\r\n" :
options.newLine === NewLineKind.LineFeed ? "\n" :
sys.newLine;

return {
getSourceFile,
getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)),
Expand Down
5 changes: 2 additions & 3 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1691,9 +1691,8 @@ module ts {
}

export const enum NewLineKind {
DEFAULT = 0,
CRLF = 1,
LF = 2,
CarriageReturnLineFeed = 0,
LineFeed = 1,
}

export interface LineAndCharacter {
Expand Down