You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/04/20 02:08:14 UTC
[3/7] 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/8ea37118
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/8ea37118
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/8ea37118
Branch: refs/heads/master
Commit: 8ea3711836c24432e665667b805a2b25f9a055f6
Parents: a5779e8
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Apr 18 11:10:29 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Apr 19 16:38:51 2012 -0700
----------------------------------------------------------------------
Jakefile | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8ea37118/Jakefile
----------------------------------------------------------------------
diff --git a/Jakefile b/Jakefile
index bbd09c6..95431cc 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 () {});
@@ -96,8 +98,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) {
@@ -137,3 +139,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);