Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Code clean up, remove unused fs require
Browse files Browse the repository at this point in the history
  • Loading branch information
shama committed Jan 29, 2014
1 parent a85eeb2 commit c8a4b63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 33 deletions.
18 changes: 8 additions & 10 deletions tasks/coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function(grunt) {
bare: false,
join: false,
sourceMap: false,
separator: grunt.util.linefeed
separator: grunt.util.linefeed,
});

options.separator = grunt.util.normalizelf(options.separator);
Expand Down Expand Up @@ -87,10 +87,10 @@ module.exports = function(grunt) {
}

options = _.extend({
generatedFile: path.basename(paths.dest),
sourceRoot: mapOptions.sourceRoot,
sourceFiles: mapOptions.sourceFiles
}, options);
generatedFile: path.basename(paths.dest),
sourceRoot: mapOptions.sourceRoot,
sourceFiles: mapOptions.sourceFiles
}, options);

var output = compileCoffee(mapOptions.code, options, filepath);
appendFooter(output, paths, options);
Expand Down Expand Up @@ -141,12 +141,10 @@ module.exports = function(grunt) {
};

var concatInput = function(files, options) {
if (!hasUniformExtensions(files)) {
return;
if (hasUniformExtensions(files)) {
var code = concatFiles(files, options.separator);
return compileCoffee(code, options);
}

var code = concatFiles(files, options.separator);
return compileCoffee(code, options);
};

var concatOutput = function(files, options) {
Expand Down
29 changes: 6 additions & 23 deletions test/coffee_test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
'use strict';

var grunt = require('grunt');
var fs = require('fs');

function readFile(file) {
'use strict';

var contents = grunt.file.read(file);

if (process.platform === 'win32') {
contents = contents.replace(/\r\n/g, '\n');
}

return contents;
}

function assertFileEquality(test, pathToActual, pathToExpected, message) {
var actual = readFile(pathToActual);
var expected = readFile(pathToExpected);
test.equal(expected, actual, message);
var actual = readFile(pathToActual);
var expected = readFile(pathToExpected);
test.equal(expected, actual, message);
}

exports.coffee = {
compileBare: function(test) {
'use strict';

test.expect(4);

assertFileEquality(test,
Expand All @@ -48,8 +43,6 @@ exports.coffee = {
test.done();
},
compileDefault: function(test) {
'use strict';

test.expect(4);

assertFileEquality(test,
Expand All @@ -75,8 +68,6 @@ exports.coffee = {
test.done();
},
compileJoined: function(test) {
'use strict';

test.expect(4);

assertFileEquality(test,
Expand All @@ -102,8 +93,6 @@ exports.coffee = {
test.done();
},
compileMaps: function(test) {
'use strict';

test.expect(10);

assertFileEquality(test,
Expand Down Expand Up @@ -159,8 +148,6 @@ exports.coffee = {
test.done();
},
compileEachMap: function(test) {
'use strict';

test.expect(4);

assertFileEquality(test,
Expand All @@ -186,8 +173,6 @@ exports.coffee = {
test.done();
},
compileSourceMapDir: function(test) {
'use strict';

test.expect(2);

assertFileEquality(test,
Expand All @@ -203,8 +188,6 @@ exports.coffee = {
test.done();
},
compileNested: function(test) {
'use strict';

test.expect(2);

assertFileEquality(test,
Expand All @@ -218,5 +201,5 @@ exports.coffee = {
'Compilation of nested maps should change per file');

test.done();
}
},
};

0 comments on commit c8a4b63

Please sign in to comment.