Skip to content

Commit 12bd522

Browse files
committed
Add "newlineKind" setting to JSON schema for api-extractor.json
1 parent b5f00a5 commit 12bd522

6 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎apps/api-extractor/src/api/ExtractorConfig.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
PackageName,
1515
Text,
1616
InternalError,
17-
Path
17+
Path,
18+
NewlineKind
1819
} from '@microsoft/node-core-library';
1920
import {
2021
IConfigFile,
@@ -95,6 +96,7 @@ interface IExtractorConfigParameters {
9596
packageJson: INodePackageJson | undefined;
9697
packageFolder: string | undefined;
9798
mainEntryPointFilePath: string;
99+
newlineKind: NewlineKind;
98100
tsconfigFilePath: string;
99101
overrideTsconfig: { } | undefined;
100102
skipLibCheck: boolean;
@@ -150,6 +152,12 @@ export class ExtractorConfig {
150152
*/
151153
public readonly packageFolder: string | undefined;
152154

155+
/**
156+
* Specifies what type of newlines API Extractor should use when writing output files.
157+
* By default, the output files will be written with POSIX-style newlines.
158+
*/
159+
public readonly newlineKind: NewlineKind;
160+
153161
/** {@inheritDoc IConfigFile.mainEntryPointFilePath} */
154162
public readonly mainEntryPointFilePath: string;
155163

@@ -202,6 +210,7 @@ export class ExtractorConfig {
202210
this.packageJson = parameters.packageJson;
203211
this.packageFolder = parameters.packageFolder;
204212
this.mainEntryPointFilePath = parameters.mainEntryPointFilePath;
213+
this.newlineKind = parameters.newlineKind;
205214
this.tsconfigFilePath = parameters.tsconfigFilePath;
206215
this.overrideTsconfig = parameters.overrideTsconfig;
207216
this.skipLibCheck = parameters.skipLibCheck;
@@ -470,6 +479,7 @@ export class ExtractorConfig {
470479
}
471480

472481
try {
482+
const newlineKind: NewlineKind = configObject.newlineKind === 'crlf' ? NewlineKind.CrLf : NewlineKind.Lf;
473483

474484
if (!configObject.compiler) {
475485
// A merged configuration should have this
@@ -644,6 +654,7 @@ export class ExtractorConfig {
644654
projectFolder: projectFolder,
645655
packageJson,
646656
packageFolder,
657+
newlineKind,
647658
mainEntryPointFilePath,
648659
tsconfigFilePath,
649660
overrideTsconfig: configObject.compiler.overrideTsconfig,

‎apps/api-extractor/src/api/IConfigFile.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,15 @@ export interface IConfigFile {
321321
*/
322322
mainEntryPointFilePath: string;
323323

324+
/**
325+
* Specifies what type of newlines API Extractor should use when writing output files.
326+
*
327+
* @remarks
328+
* By default, the output files will be written with POSIX-style newlines. To use Windows-style newlines,
329+
* specify `crlf` instead.
330+
*/
331+
newlineKind?: 'crlf' | 'lf';
332+
324333
/**
325334
* {@inheritDoc IConfigCompiler}
326335
*/

‎apps/api-extractor/src/schemas/api-extractor-defaults.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
"projectFolder": "<lookup>",
55

6+
"newlineKind": "lf",
7+
68
"compiler": {
79
"tsconfigFilePath": "<projectFolder>/tsconfig.json",
810
"skipLibCheck": false

‎apps/api-extractor/src/schemas/api-extractor-template.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
4747
*/
4848
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
4949

50+
/**
51+
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
52+
* will be written with POSIX-style newlines. To use Windows-style newlines, specify "crlf" instead.
53+
* DEFAULT VALUE: "lf"
54+
*/
55+
// "newlineKind": "crlf",
56+
5057
/**
5158
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
5259
*/

‎apps/api-extractor/src/schemas/api-extractor.schema.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
"type": "string"
2424
},
2525

26+
"newlineKind": {
27+
"description": "Specifies what type of newlines API Extractor should use when writing output files. By default, the output files will be written with POSIX-style newlines. To use Windows-style newlines, specify \"crlf\" instead.",
28+
"type": "string",
29+
"enum": [ "crlf", "lf" ]
30+
},
31+
2632
"compiler": {
2733
"description": "Determines how the TypeScript compiler engine will be invoked by API Extractor.",
2834
"type": "object",

‎common/reviews/api/api-extractor.api.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { INodePackageJson } from '@microsoft/node-core-library';
88
import { JsonSchema } from '@microsoft/node-core-library';
9+
import { NewlineKind } from '@microsoft/node-core-library';
910
import * as ts from 'typescript';
1011
import * as tsdoc from '@microsoft/tsdoc';
1112

@@ -52,6 +53,7 @@ export class ExtractorConfig {
5253
static loadFileAndPrepare(configJsonFilePath: string): ExtractorConfig;
5354
readonly mainEntryPointFilePath: string;
5455
readonly messages: IExtractorMessagesConfig;
56+
readonly newlineKind: NewlineKind;
5557
readonly omitTrimmingComments: boolean;
5658
readonly overrideTsconfig: {} | undefined;
5759
readonly packageFolder: string | undefined;
@@ -182,6 +184,7 @@ export interface IConfigFile {
182184
extends?: string;
183185
mainEntryPointFilePath: string;
184186
messages?: IExtractorMessagesConfig;
187+
newlineKind?: 'crlf' | 'lf';
185188
projectFolder?: string;
186189
testMode?: boolean;
187190
// @beta

0 commit comments

Comments
 (0)