Skip to content

Commit a15a94f

Browse files
authored
Merge pull request #48 from radziksh/master
Adding the possibility of inserting an arbitrary EOF
2 parents 3d7722f + 8dbf69c commit a15a94f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ You can set the following options:
129129
* `option.searchDir`: Directory which includes target `*.css` files(default: `'./'`).
130130
* `option.outDir`: Output directory(default: `option.searchDir`).
131131
* `option.camelCase`: Camelize CSS class tokens.
132+
* `option.EOL`: EOL (end of line) for the generated `d.ts` files. Possible values `'\n'` or `'\r\n'`(default: `os.EOL`).
132133

133134
#### `create(filepath, contents) => Promise(dtsContent)`
134135
Returns `DtsContent` instance.

src/dtsCreator.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class DtsContent {
2828
rInputPath,
2929
rawTokenList,
3030
resultList,
31-
messageList
31+
messageList,
32+
EOL
3233
}) {
3334
this.dropExtension = dropExtension;
3435
this.rootDir = rootDir;
@@ -38,6 +39,7 @@ class DtsContent {
3839
this.rawTokenList = rawTokenList;
3940
this.resultList = resultList;
4041
this.messageList = messageList;
42+
this.EOL = EOL;
4143
}
4244

4345
get contents() {
@@ -46,7 +48,7 @@ class DtsContent {
4648

4749
get formatted() {
4850
if(!this.resultList || !this.resultList.length) return '';
49-
return this.resultList.join(os.EOL);
51+
return this.resultList.join(this.EOL);
5052
}
5153

5254
get tokens() {
@@ -68,7 +70,7 @@ class DtsContent {
6870
mkdirp.sync(outPathDir);
6971
}
7072
return new Promise((resolve, reject) => {
71-
fs.writeFile(this.outputFilePath, this.formatted + os.EOL, 'utf8', (err) => {
73+
fs.writeFile(this.outputFilePath, this.formatted + this.EOL, 'utf8', (err) => {
7274
if(err) {
7375
reject(err);
7476
}else{
@@ -90,6 +92,7 @@ export class DtsCreator {
9092
this.outputDirectory = path.join(this.rootDir, this.outDir);
9193
this.camelCase = options.camelCase;
9294
this.dropExtension = !!options.dropExtension;
95+
this.EOL = options.EOL || os.EOL;
9396
}
9497

9598
create(filePath, initialContents, clearCache = false) {
@@ -132,7 +135,8 @@ export class DtsCreator {
132135
rInputPath,
133136
rawTokenList: keys,
134137
resultList: result,
135-
messageList
138+
messageList,
139+
EOL: this.EOL
136140
});
137141

138142
resolve(content);

0 commit comments

Comments
 (0)