Skip to content

Commit

Permalink
Compiler flag to specify line ending microsoft#1693
Browse files Browse the repository at this point in the history
  • Loading branch information
kmashint committed May 3, 2015
1 parent 1625a6c commit 532f92b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ module ts {
paramType: Diagnostics.KIND,
error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
},
{
name: "newLine",
type: { "crlf": NewLineKind.CRLF, "lf": NewLineKind.LF },
description: Diagnostics.Emit_newline_Colon_CRLF_dos_or_LF_unix,
paramType: Diagnostics.NEWLINE,
error: Diagnostics.Argument_for_newLine_option_must_be_CRLF_or_LF
},
{
name: "noEmit",
type: "boolean",
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/diagnosticInformationMap.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ module ts {
Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
Emit_newline_Colon_CRLF_dos_or_LF_unix: { code: 6061, category: DiagnosticCategory.Message, key: "Emit newline: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6062, category: DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6063, category: DiagnosticCategory.Error, key: "Argument for --newLine option must be 'CRLF' or 'LF'." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
Expand Down
12 changes: 12 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,18 @@
"category": "Error",
"code": 6059
},
"Emit newline: 'CRLF' (dos) or 'LF' (unix).": {
"category": "Message",
"code": 6061
},
"NEWLINE": {
"category": "Message",
"code": 6062
},
"Argument for --newLine option must be 'CRLF' or 'LF'.": {
"category": "Error",
"code": 6063
},


"Variable '{0}' implicitly has an '{1}' type.": {
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ module ts {
}
}

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

return {
getSourceFile,
getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)),
writeFile,
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
getCanonicalFileName,
getNewLine: () => sys.newLine
getNewLine: () => newLine
};
}

Expand Down
7 changes: 7 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,7 @@ module ts {
locale?: string;
mapRoot?: string;
module?: ModuleKind;
newLine?: string;
noEmit?: boolean;
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
Expand Down Expand Up @@ -1689,6 +1690,12 @@ module ts {
System = 4,
}

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

export interface LineAndCharacter {
line: number;
/*
Expand Down

0 comments on commit 532f92b

Please sign in to comment.