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

Improvement/use os line endings #12

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# 0.3.4

* Use EOL instead of \r\n - [PR by @Jimmerz28](https://github.com/pedsmoreira/battlecry/pull/12)

# 0.3.3

* Battlecry now works locally (npm install --save battlecry)
* Battlecry now works locally (npm install --save battlecry) - [PR by @raulfdm](https://github.com/pedsmoreira/battlecry/pull/6)

# 0.3.2

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"flow-typed": "^2.4.0",
"husky": "^0.14.3",
"jest": "^22.4.3",
"lint-staged": "^7.0.2",
"lint-staged": "^8.1.0",
"prettier": "^1.11.1"
},
"lint-staged": {
Expand Down
3 changes: 2 additions & 1 deletion src/classes/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fs from 'fs';
import mkdirp from 'mkdirp';
import { basename, dirname, extname } from 'path';
import { EOL } from 'os';
import isBinaryFile from 'isbinaryfile';

import glob from '../helpers/glob';
Expand Down Expand Up @@ -93,7 +94,7 @@ export default class File {
*/

static joinLines(lines: string[]): string {
return lines.join('\r\n');
return lines.join(EOL);
}

readText() {
Expand Down
5 changes: 3 additions & 2 deletions tests/classes/File.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { File } from 'battlecry';
import rimraf from 'rimraf';
import { EOL } from 'os';
import fs from 'fs';

const tmpPath = `${__dirname}/File-tmp`;
Expand Down Expand Up @@ -203,7 +204,7 @@ describe('File', () => {
});

it('returns lines joined by \r\n', () => {
expect(File.joinLines(['a', 'b', 'c'])).toEqual('a\r\nb\r\nc');
expect(File.joinLines(['a', 'b', 'c'])).toEqual(`a${EOL}b${EOL}c`);
});
});

Expand Down Expand Up @@ -259,7 +260,7 @@ describe('File', () => {
describe('#lines=', () => {
it('sets text joined by \r\n', () => {
textFile.lines = [1, 'b', 3];
expect(textFile.text).toEqual('1\r\nb\r\n3');
expect(textFile.text).toEqual(`1${EOL}b${EOL}3`);
});
});

Expand Down
3 changes: 2 additions & 1 deletion tests/helpers/namedCasex.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { namedCasex } from 'battlecry';
import { EOL } from 'os';

describe('namedCasex', () => {
it('replaces all __name__ occurrences', () => {
Expand All @@ -10,7 +11,7 @@ describe('namedCasex', () => {

it('transforms array into multiline text', () => {
const text = ['Hi', 'my name is __Na Me__'];
const transformedText = 'Hi\r\nmy name is John Doe';
const transformedText = `Hi${EOL}my name is John Doe`;

expect(namedCasex(text, 'john-doe')).toEqual(transformedText);
});
Expand Down
Loading