Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
feat: add eol config option
Browse files Browse the repository at this point in the history
Closes #7
  • Loading branch information
justinlettau committed Dec 15, 2020
1 parent 62a5513 commit a5ca82e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Config
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v2

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ following properties are supported.

**includeConstraintName** (`boolean`): Optional. Indicates if constraint names should be scripted. Default is `false`.

**eol** (`string`: Optional. Line ending character (`auto`, `crlf`, or `lf`). Default is `auto`.

Note: See [Git documentation](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whitespace) for information about how Git handles line endings.

# Examples

### Connections
Expand Down
3 changes: 2 additions & 1 deletion docker/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"Person.CountryRegion",
"Person.PhoneNumberType",
"Purchasing.ShipMethod"
]
],
"eol": "crlf"
}
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"checksum": "^0.1.1",
"cli-table": "^0.3.4",
"commander": "^6.2.0",
"eol": "^0.9.1",
"filenamify": "^4.2.0",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
Expand Down
6 changes: 6 additions & 0 deletions src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ export default class Config implements IConfig {
*/
includeConstraintName = false;

/**
* Line ending character.
*/
eol: 'auto' | 'crlf' | 'lf' = 'auto';

/**
* Get root output directory.
*/
Expand Down Expand Up @@ -237,6 +242,7 @@ export default class Config implements IConfig {
Object.assign(this.idempotency, config.idempotency);
this.includeConstraintName =
config.includeConstraintName || this.includeConstraintName;
this.eol = config.eol || this.eol;
} catch (error) {
console.error(
'Could not find or parse config file. You can use the `init` command to create one!'
Expand Down
15 changes: 15 additions & 0 deletions src/common/file-utility.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import chalk = require('chalk');
import * as checksum from 'checksum';
import * as eol from 'eol';
import filenamify = require('filenamify');
import * as fs from 'fs-extra';
import * as glob from 'glob';
Expand Down Expand Up @@ -71,6 +72,20 @@ export default class FileUtility {
}

file = path.join(this.config.getRoot(), dir, file);

switch (this.config.eol) {
case 'crlf':
content = eol.crlf(content);
break;
case 'lf':
content = eol.lf(content);
break;
case 'auto':
default:
content = eol.auto(content);
break;
}

content = content.trim();

const cacheKey = this.normalize(file);
Expand Down

0 comments on commit a5ca82e

Please sign in to comment.