@@ -16,10 +16,16 @@ export const enum Encoding {
1616 * Enumeration controlling conversion of newline characters.
1717 * @public
1818 */
19- export enum NewlineConversion {
20- CrLf ,
21- Lf ,
22- None
19+ export const enum NewlineKind {
20+ /**
21+ * Windows-style newlines
22+ */
23+ CrLf = '\r\n' ,
24+
25+ /**
26+ * Unix-style newlines
27+ */
28+ Lf = '\n'
2329}
2430
2531/**
@@ -47,9 +53,9 @@ export interface IWriteFileOptions {
4753
4854 /**
4955 * If specified, will normalize line endings to the specified style of newline.
50- * Defaults to `NewlineConversion .None`.
56+ * Defaults to `NewlineKind .None`.
5157 */
52- convertLineEndings ?: NewlineConversion ;
58+ convertLineEndings ?: NewlineKind ;
5359
5460 /**
5561 * If specified, will change the encoding of the file that will be written.
@@ -71,9 +77,9 @@ export interface IReadFileOptions {
7177
7278 /**
7379 * If specified, will normalize line endings to the specified style of newline.
74- * Defaults to `NewlineConversion .None`.
80+ * Defaults to `NewlineKind .None`.
7581 */
76- convertLineEndings ?: NewlineConversion ;
82+ convertLineEndings ?: NewlineKind ;
7783}
7884
7985/**
@@ -246,7 +252,7 @@ export class FileSystem {
246252 public static writeFile ( filePath : string , contents : string , options ?: IWriteFileOptions ) : void {
247253 options = {
248254 ensureFolder : false ,
249- convertLineEndings : NewlineConversion . None ,
255+ convertLineEndings : undefined ,
250256 encoding : Encoding . Utf8 ,
251257 ...options
252258 } ;
@@ -270,7 +276,7 @@ export class FileSystem {
270276 public static readFile ( filePath : string , options ?: IReadFileOptions ) : string {
271277 options = {
272278 encoding : Encoding . Utf8 ,
273- convertLineEndings : NewlineConversion . None ,
279+ convertLineEndings : undefined ,
274280 ...options
275281 } ;
276282
@@ -373,10 +379,10 @@ export class FileSystem {
373379 * @param text - The text to be normalized.
374380 * @param lineEndings - The style of line endings to use.
375381 */
376- private static _convertLineEndings ( text : string , lineEndings : NewlineConversion | undefined ) : string {
377- if ( lineEndings === NewlineConversion . CrLf ) {
382+ private static _convertLineEndings ( text : string , lineEndings : NewlineKind | undefined ) : string {
383+ if ( lineEndings === NewlineKind . CrLf ) {
378384 return Text . convertToCrLf ( text ) ;
379- } else if ( lineEndings === NewlineConversion . Lf ) {
385+ } else if ( lineEndings === NewlineKind . Lf ) {
380386 return Text . convertToLf ( text ) ;
381387 }
382388 return text ;
0 commit comments