NewlinesTransformer
Extends:
A transformer that handles newline characters in files. During a pull, all breaks are converted the OS-native EOL character and (optionally) a trailing newline is added (for better git diffs). On push, CRLF characters are used and those trailing newlines are removed again.
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) Creates a new newline transformer. |
Member Summary
Public Members | ||
public get |
|
Private Members | ||
private |
If newlines should be added to pulled files. |
Method Summary
Public Methods | ||
public |
shouldBeTransformed(file: AtviseFile): boolean Returns |
|
public |
transformFromDB(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) Adds converts line breaks to the current OS's native EOL characters and adds trailing newlines. |
|
public |
transformFromFilesystem(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) Removes trailing newlines and converts all breaks to CRLF. |
Public Constructors
Public Members
public get transformsReferenceConfigFiles: boolean source
true
because we want to transform all files.
Private Members
Public Methods
public shouldBeTransformed(file: AtviseFile): boolean source
Returns true
for all files except binary ones.
Params:
Name | Type | Attribute | Description |
file | AtviseFile | The file being transformed. |
Test:
public transformFromDB(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) source
Adds converts line breaks to the current OS's native EOL characters and adds trailing newlines.
Params:
Name | Type | Attribute | Description |
file | AtviseFile | The file being transformed. |
|
enc | string | The encoding used. |
|
callback | function(err: ?Error, data: ?AtviseFile) | Called with the corrected file. |
Test:
public transformFromFilesystem(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) source
Removes trailing newlines and converts all breaks to CRLF.
Params:
Name | Type | Attribute | Description |
file | AtviseFile | The file being transformed. |
|
enc | string | The encoding used. |
|
callback | function(err: ?Error, data: ?AtviseFile) | Called with resulting file. |