Permalink
Browse files

Code cleanup

Also, added jshint to help.
  • Loading branch information...
1 parent 37ef509 commit cfd69586822d6ae368d0521cc886a84e89d9b049 @jgonera committed Feb 14, 2013
Showing with 23 additions and 11 deletions.
  1. +10 −0 .jshintrc
  2. +2 −1 Makefile
  3. +4 −4 lib/lessfile.js
  4. +6 −6 lib/manager.js
  5. +1 −0 package.json
View
@@ -0,0 +1,10 @@
+{
+ "node": true,
+ "strict": false,
+ "eqeqeq": true,
+ "forin": false,
+ "trailing": true,
+ "undef" : true,
+ "unused": true,
+ "supernew": true
+}
View
@@ -1,4 +1,5 @@
test:
- node_modules/mocha/bin/mocha --require test/env
+ node_modules/.bin/jshint lib/* --config .jshintrc
+ node_modules/.bin/mocha --reporter spec --require test/env
.PHONY: test
View
@@ -15,7 +15,7 @@ function LessFile(file, dstFile) {
LessFile.prototype = {
parse: function(callback) {
var self = this;
- this.parser.parse(fs.readFileSync(this.file, 'utf-8'), function(err, tree) {
+ this.parser.parse(fs.readFileSync(this.file, 'utf-8'), function(err) {
self.imports = Object.keys(self.parser.imports.files);
callback(err);
});
@@ -25,13 +25,13 @@ LessFile.prototype = {
var self = this;
this.parser.parse(fs.readFileSync(this.file, 'utf-8'), function(err, tree) {
if (err) {
- callback(err, self);
+ callback(err);
} else {
try {
fs.writeFileSync(self.dstFile, tree.toCSS(), 'utf-8');
- callback(null, self);
+ callback(null);
} catch (err) {
- callback(err, self);
+ callback(err);
}
}
});
View
@@ -17,7 +17,7 @@ Manager.prototype._update = function(file, callback) {
var self = this, lessFile = this.files[file];
if (!lessFile) {
- var base = file.match(/^(.*)\.[^\.]*$/)[1]
+ var base = file.match(/^(.*)\.[^\.]*$/)[1];
var dstFile = path.join(this.dstDir, base.slice(this.srcDir.length) + '.css');
lessFile = this.files[file] = new LessFile(file, dstFile);
}
@@ -27,14 +27,14 @@ Manager.prototype._update = function(file, callback) {
self.dependencies[importFile] = self.dependencies[importFile] || {};
self.dependencies[importFile][lessFile.file] = true;
});
- callback(err, lessFile);
+ callback(err);
});
};
Manager.prototype.addFiles = function(files, callback) {
var self = this, pending = files.length;
- function done(err) {
+ function done() {
--pending;
if (pending === 0) callback();
}
@@ -53,8 +53,8 @@ Manager.prototype._compileBatch = function(files, callback) {
--pending;
if (pending === 0) {
self.emit('checkSummary', summary);
- callback(errors)
- };
+ callback(errors);
+ }
}
function compile(file) {
@@ -92,7 +92,7 @@ Manager.prototype.check = function(file, callback) {
if (this.ignore) return;
- this._update(file, function(err) {
+ this._update(file, function() {
if (self.dependencies[file]) {
self._compileBatch([file].concat(Object.keys(self.dependencies[file])), callback);
} else {
View
@@ -14,6 +14,7 @@
"less": "1.3.3"
},
"devDependencies": {
+ "jshint": "*",
"mocha": "*",
"chai": "*",
"sinon": "*"

0 comments on commit cfd6958

Please sign in to comment.