Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 893e324

Browse filesBrowse files
author
Andy Hanson
committed
Don't access sys.newLine inside unit tests
1 parent 1798e8f commit 893e324
Copy full SHA for 893e324

3 files changed

+5-16Lines changed: 5 additions & 16 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/commandLineParser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/commandLineParser.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ namespace ts {
895895
* @param fileNames array of filenames to be generated into tsconfig.json
896896
*/
897897
/* @internal */
898-
export function generateTSConfig(options: CompilerOptions, fileNames: string[]): string {
898+
export function generateTSConfig(options: CompilerOptions, fileNames: string[], newLine: string): string {
899899
const compilerOptions = extend(options, defaultInitCompilerOptions);
900900
const configurations: { compilerOptions: MapLike<CompilerOptionsValue>; files?: string[] } = {
901901
compilerOptions: serializeCompilerOptions(compilerOptions)
@@ -1053,7 +1053,7 @@ namespace ts {
10531053
}
10541054
result.push(`}`);
10551055

1056-
return result.join(sys.newLine);
1056+
return result.join(newLine);
10571057
}
10581058
}
10591059

Collapse file

‎src/compiler/tsc.ts‎

Copy file name to clipboardExpand all lines: src/compiler/tsc.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ namespace ts {
739739
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* host */ undefined);
740740
}
741741
else {
742-
sys.writeFile(file, generateTSConfig(options, fileNames));
742+
sys.writeFile(file, generateTSConfig(options, fileNames, sys.newLine));
743743
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* host */ undefined);
744744
}
745745

Collapse file

‎src/harness/unittests/initializeTSConfig.ts‎

Copy file name to clipboardExpand all lines: src/harness/unittests/initializeTSConfig.ts
+2-13Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,11 @@ namespace ts {
66
function initTSConfigCorrectly(name: string, commandLinesArgs: string[]) {
77
describe(name, () => {
88
const commandLine = parseCommandLine(commandLinesArgs);
9-
const initResult = generateTSConfig(commandLine.options, commandLine.fileNames);
9+
const initResult = generateTSConfig(commandLine.options, commandLine.fileNames, "\n");
1010
const outputFileName = `tsConfig/${name.replace(/[^a-z0-9\-. ]/ig, "")}/tsconfig.json`;
1111

1212
it(`Correct output for ${outputFileName}`, () => {
13-
Harness.Baseline.runBaseline(outputFileName, () => {
14-
if (initResult) {
15-
// normalize line endings
16-
return initResult.replace(new RegExp(sys.newLine, "g"), "\n");
17-
}
18-
else {
19-
// This can happen if compiler recieve invalid compiler-options
20-
/* tslint:disable:no-null-keyword */
21-
return null;
22-
/* tslint:enable:no-null-keyword */
23-
}
24-
});
13+
Harness.Baseline.runBaseline(outputFileName, () => initResult);
2514
});
2615
});
2716
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.