Skip to content

Commit

Permalink
Force LF line endings on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed May 30, 2016
1 parent 6ed2b8b commit 37c011d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text eol=lf
4 changes: 0 additions & 4 deletions appveyor.yml
@@ -1,9 +1,5 @@
# http://www.appveyor.com/docs/appveyor-yml

# Fix line endings in Windows. (runs before repo cloning)
init:
- git config --global core.autocrlf true

# Test against these versions of Node.js.
environment:
matrix:
Expand Down
34 changes: 14 additions & 20 deletions test/test.js
Expand Up @@ -12,12 +12,6 @@ var firstFixture = path.join(__dirname, 'fixtures', 'first');
var secondFixture = path.join(__dirname, 'fixtures', 'second');
var builder;

function readFileSync() {
// babel doesn't support Windows newlines
// https://github.com/babel/babel/pull/2290
return fs.readFileSync.apply(this, arguments).replace(/\r\n/g, '\n');
}

describe('sourcemap-concat', function() {
it('concatenates files in one dir', function() {
var node = concat(firstFixture, {
Expand Down Expand Up @@ -160,7 +154,7 @@ describe('sourcemap-concat', function() {
var expected = path.join(__dirname, 'expected', 'all-with-source-root.map');
var actual = path.join(result.directory, 'all-with-source-root.map');

expect(readFileSync(actual, 'UTF-8')).to.equal(readFileSync(expected, 'UTF-8'));
expect(fs.readFileSync(actual, 'UTF-8')).to.equal(fs.readFileSync(expected, 'UTF-8'));
});
});

Expand Down Expand Up @@ -199,11 +193,11 @@ describe('sourcemap-concat', function() {

builder = new broccoli.Builder(final);
return builder.build().then(function(result) {
var actual = readFileSync(result.directory + '/staged.js', 'UTF-8');
var actual = fs.readFileSync(result.directory + '/staged.js', 'UTF-8');

var firstFixture = path.join(__dirname, 'fixtures', 'first');
var first = readFileSync(path.join(firstFixture, 'inner/first.js'), 'UTF-8');
var second = readFileSync(path.join(firstFixture, 'inner/second.js'), 'UTF-8');
var first = fs.readFileSync(path.join(firstFixture, 'inner/first.js'), 'UTF-8');
var second = fs.readFileSync(path.join(firstFixture, 'inner/second.js'), 'UTF-8');

var expected = first + '\n' + second;
expect(actual).to.equal(expected, 'output is wrong');
Expand All @@ -218,11 +212,11 @@ describe('sourcemap-concat', function() {

builder = new broccoli.Builder(final);
return builder.build().then(function(result) {
var actual = readFileSync(result.directory + '/staged.js', 'UTF-8');
var actual = fs.readFileSync(result.directory + '/staged.js', 'UTF-8');

var firstFixture = path.join(__dirname, 'fixtures', 'first');
var first = readFileSync(path.join(firstFixture, 'inner/first.js'), 'UTF-8');
var second = readFileSync(path.join(firstFixture, 'inner/second.js'), 'UTF-8');
var first = fs.readFileSync(path.join(firstFixture, 'inner/first.js'), 'UTF-8');
var second = fs.readFileSync(path.join(firstFixture, 'inner/second.js'), 'UTF-8');

var expected = first + '\n' + second + '//# sourceMappingURL=staged.map';
expect(actual).to.equal(expected, 'output is wrong');
Expand Down Expand Up @@ -381,16 +375,16 @@ describe('concat-without-maps', function() {
concat.addSpace('b');
concat.addSpace('c');
concat.end();
expect(readFileSync(outputFile, 'UTF-8')).to.equal('abc');
expect(fs.readFileSync(outputFile, 'UTF-8')).to.equal('abc');
});

it('addFile', function() {
concat.addFile('inner/first.js');
concat.addFile('inner/second.js');
concat.addFile('other/third.js');
concat.end();
expect(readFileSync(outputFile, 'UTF-8'))
.to.equal(readFileSync(__dirname + '/expected/concat-without-maps-1.js', 'UTF-8'));
expect(fs.readFileSync(outputFile, 'UTF-8'))
.to.equal(fs.readFileSync(__dirname + '/expected/concat-without-maps-1.js', 'UTF-8'));
});

it('addFile & addSpace', function() {
Expand All @@ -400,8 +394,8 @@ describe('concat-without-maps', function() {
concat.addSpace('"c";\n');
concat.addFile('inner/second.js');
concat.end();
expect(readFileSync(outputFile, 'UTF-8'))
.to.equal(readFileSync(__dirname + '/expected/concat-without-maps-2.js', 'UTF-8'));
expect(fs.readFileSync(outputFile, 'UTF-8'))
.to.equal(fs.readFileSync(__dirname + '/expected/concat-without-maps-2.js', 'UTF-8'));
});
});

Expand All @@ -414,13 +408,13 @@ function expectFile(filename) {
subdir = '.';
}

var actualContent = readFileSync(path.join(result.directory, subdir, filename), 'utf-8');
var actualContent = fs.readFileSync(path.join(result.directory, subdir, filename), 'utf-8');
fs.writeFileSync(path.join(__dirname, 'actual', filename), actualContent);

var expectedContent;

try {
expectedContent = readFileSync(path.join(__dirname, 'expected', filename), 'utf-8');
expectedContent = fs.readFileSync(path.join(__dirname, 'expected', filename), 'utf-8');
if (stripURL) {
expectedContent = expectedContent.replace(/\/\/# sourceMappingURL=.*$/, '');
}
Expand Down

0 comments on commit 37c011d

Please sign in to comment.