You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/04/20 02:21:40 UTC
[7/15] git commit: added a fixtabs task to convert tabs to spaces,
which jshint depends on
added a fixtabs task to convert tabs to spaces, which jshint depends on
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/411600a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/411600a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/411600a3
Branch: refs/heads/master
Commit: 411600a34f8f9aa1d869156bc441c6046e63662e
Parents: 71008aa
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Apr 18 11:10:29 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Thu Apr 19 17:21:06 2012 -0700
----------------------------------------------------------------------
Jakefile | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/411600a3/Jakefile
----------------------------------------------------------------------
diff --git a/Jakefile b/Jakefile
index b7ceb8a..a75e39d 100644
--- a/Jakefile
+++ b/Jakefile
@@ -7,7 +7,8 @@ var util = require('util'),
rexp_minified = new RegExp("\\.min\\.js$"),
rexp_src = new RegExp('\\.js$');
-
+// HELPERS
+// Iterates over a directory
function forEachFile(root, cbFile, cbDone) {
var count = 0;
@@ -42,6 +43,7 @@ function forEachFile(root, cbFile, cbDone) {
scan(root);
}
+
desc("runs build");
task('default', ['build','test'], function () {});
@@ -97,8 +99,8 @@ task('set-cwd', [], function() {
});
// Taken shamelessly from Jakefile from https://github.com/marcenuc/sammy
-desc('Check sources with JSHint.');
-task('hint', function () {
+desc('check sources with JSHint');
+task('hint', ['fixtabs'], function () {
var JSHINT = require('jshint').JSHINT;
function checkFile(file, cbDone) {
@@ -138,3 +140,20 @@ task('hint', function () {
checkFile('Jakefile', complete);
});
}, true);
+
+desc('converts tabs to four spaces - enforcing style guide ftw!');
+task('fixtabs', function() {
+ forEachFile('lib', function(err, file, stats, cbDone) {
+ if (err) throw err;
+ if (rexp_minified.test(file) || !rexp_src.test(file)) {
+ cbDone();
+ } else {
+ var src = fs.readFileSync(file, 'utf8');
+ if (src.indexOf('\t') >= 0) {
+ src = src.split('\t').join(' ');
+ fs.writeFileSync(file, src, 'utf8');
+ }
+ cbDone();
+ }
+ }, complete);
+}, true);