Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed May 2, 2012
2 parents 06c3a47 + 9cfdc13 commit ce66890
Show file tree
Hide file tree
Showing 127 changed files with 1,781 additions and 1,150 deletions.
141 changes: 141 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// Defaults as of jshint edition 2011-04-16
{
// If the scan should stop on first error.
"passfail": false,
// Maximum errors before stopping.
"maxerr": 50,


// Predefined globals
// If the standard browser globals should be predefined.
"browser": true,
// If the Node.js environment globals should be predefined.
"node": true,
// If the Rhino environment globals should be predefined.
"rhino": false,
// If CouchDB globals should be predefined.
"couch": false,
// If the Windows Scripting Host environment globals should be predefined.
"wsh": false,

// If jQuery globals should be predefined.
"jquery": false,
// If Prototype and Scriptaculous globals should be predefined.
"prototypejs": false,
// If MooTools globals should be predefined.
"mootools": false,
// If Dojo Toolkit globals should be predefined.
"dojo": false,

// Custom predefined globals.
"predef": ["jasmine", "blackberry", "define", "alert", "prompt", "org", "deviceapis", "Osp"],


// Development
// If debugger statements should be allowed.
"debug": false,
// If logging globals should be predefined (console, alert, etc.).
"devel": false,


// ECMAScript 5
// If ES5 syntax should be allowed.
"es5": false,
// Require the "use strict"; pragma.
"strict": false,
// If global "use strict"; should be allowed (also enables strict).
"globalstrict": false,


// The Good Parts
// If automatic semicolon insertion should be tolerated.
"asi": false,
// If line breaks should not be checked, e.g. `return [\n] x`.
"laxbreak": false,
// If bitwise operators (&, |, ^, etc.) should not be allowed.
"bitwise": false,
// If assignments inside if, for and while should be allowed. Usually
// conditions and loops are for comparison, not assignments.
"boss": true,
// If curly braces around all blocks should be required.
"curly": false,
// If === should be required.
"eqeqeq": false,
// If == null comparisons should be tolerated.
"eqnull": false,
// If eval should be allowed.
"evil": true,
// If ExpressionStatement should be allowed as Programs.
"expr": true,
// If `for in` loops must filter with `hasOwnPrototype`.
"forin": false,
// If immediate invocations must be wrapped in parens, e.g.
// `( function(){}() );`.
"immed": false,
// If use before define should not be tolerated.
"latedef": false,
// If functions should be allowed to be defined within loops.
"loopfunc": true,
// If arguments.caller and arguments.callee should be disallowed.
"noarg": false,
// If the . should not be allowed in regexp literals.
"regexp": false,
// If unescaped first/last dash (-) inside brackets should be tolerated.
"regexdash": false,
// If script-targeted URLs should be tolerated.
"scripturl": false,
// If variable shadowing should be tolerated.
"shadow": false,
// If `new function () { ... };` and `new Object;` should be tolerated.
"supernew": false,
// If variables should be declared before used.
"undef": true,
// If `this` inside a non-constructor function is valid.
"validthis": false,
// If smarttabs should be tolerated
// (http://www.emacswiki.org/emacs/SmartTabs).
"smarttabs": false,
// If the `__proto__` property should be allowed.
"proto": false,
// If one case switch statements should be allowed.
"onecase": false,
// If non-standard (but widely adopted) globals should be predefined.
"nonstandard": false,
// Allow multiline strings.
"multistr": false,
// If line breaks should not be checked around commas.
"laxcomma": false,
// If semicolons may be ommitted for the trailing statements inside of a
// one-line blocks.
"lastsemic": false,
// If the `__iterator__` property should be allowed.
"iterator": false,
// If only function scope should be used for scope tests.
"funcscope": false,
// If es.next specific syntax should be allowed.
"esnext": false,


// Style preferences
// If constructor names must be capitalized.
"newcap": false,
// If empty blocks should be disallowed.
"noempty": false,
// If using `new` for side-effects should be disallowed.
"nonew": false,
// If names should be checked for leading or trailing underscores
// (object._attribute would be disallowed).
"nomen": false,
// If only one var statement per function should be allowed.
"onevar": false,
// If increment and decrement (`++` and `--`) should not be allowed.
"plusplus": false,
// If all forms of subscript notation are tolerated.
"sub": false,
// If trailing whitespace rules apply.
"trailing": true,
// If strict whitespace rules apply.
"white": false,
// Specify indentation.
"indent": 4
}
116 changes: 98 additions & 18 deletions Jakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,50 @@

var util = require('util')
var fs = require('fs')
var childProcess = require('child_process')
var path = require("path")
var util = require('util'),
fs = require('fs'),
childProcess = require('child_process'),
path = require("path"),
rexp_minified = new RegExp("\\.min\\.js$"),
rexp_src = new RegExp('\\.js$');

// HELPERS
// Iterates over a directory
function forEachFile(root, cbFile, cbDone) {
var count = 0;

function scan(name) {
++count;

fs.stat(name, function (err, stats) {
if (err) cbFile(err);

if (stats.isDirectory()) {
fs.readdir(name, function (err, files) {
if (err) cbFile(err);

files.forEach(function (file) {
scan(path.join(name, file));
});
done();
});
} else if (stats.isFile()) {
cbFile(null, name, stats, done);
} else {
done();
}
});
}

function done() {
--count;
if (count === 0 && cbDone) cbDone();
}

scan(root);
}


desc("runs build");
task('default', ['build', 'test'], function () {});
task('default', ['build','test'], function () {});

desc("clean");
task('clean', ['set-cwd'], function () {
Expand All @@ -18,36 +57,32 @@ task('clean', ['set-cwd'], function () {
}, true);

desc("compiles the source files for all extensions");
task('build', ['clean'], function () {

task('build', ['clean', 'hint'], function () {
var packager = require("./build/packager");
var commitId = "";
childProcess.exec("git log -1",function(err,stdout,stderr)
{
childProcess.exec("git log -1",function(err,stdout,stderr) {
var stdoutLines = stdout.split("\n");
if(stdoutLines.length > 0)
{
if(stdoutLines.length > 0) {
commitId = stdoutLines[0];
}

console.log("commitId = " + commitId);
console.log("building " + commitId);
packager.generate("blackberry",commitId);
packager.generate("playbook",commitId);
packager.generate("ios",commitId);
packager.generate("wp7",commitId);
packager.generate("android",commitId);
packager.generate("bada",commitId);
packager.generate("errgen",commitId);
packager.generate("test",commitId);
complete();
});



});
}, true);

desc("prints a dalek");
task('dalek', ['set-cwd'], function () {
util.puts(fs.readFileSync("build/dalek", "utf-8"));
})
});

desc("runs the unit tests in node");
task('test', ['set-cwd'], require('./test/runner').node);
Expand All @@ -58,7 +93,52 @@ task('btest', ['set-cwd'], require('./test/runner').browser);
desc("make sure we're in the right directory");
task('set-cwd', [], function() {
if (__dirname != process.cwd()) {
process.chdir(__dirname)
process.chdir(__dirname);
}
});

desc('check sources with JSHint');
task('hint', ['fixwhitespace'], function () {
var knownWarnings = ["Redefinition of 'FileReader'", "Redefinition of 'require'", "Read only"];
var filterKnownWarnings = function(el, index, array) {
var wut = true;
// filter out the known warnings listed out above
knownWarnings.forEach(function(e) {
wut = wut && (el.indexOf(e) == -1);
});
wut = wut && (!el.match(/\d+ errors/));
return wut;
};

childProcess.exec("jshint lib",function(err,stdout,stderr) {
var exs = stdout.split('\n');
console.log(exs.filter(filterKnownWarnings).join('\n'));
complete();
});
}, true);

desc('converts tabs to four spaces, eliminates trailing white space, converts newlines to proper form - enforcing style guide ftw!');
task('fixwhitespace', function() {
forEachFile('lib', function(err, file, stats, cbDone) {
//if (err) throw err;
if (rexp_minified.test(file) || !rexp_src.test(file)) {
cbDone();
} else {
var origsrc = src = fs.readFileSync(file, 'utf8');

// tabs -> four spaces
if (src.indexOf('\t') >= 0) {
src = src.split('\t').join(' ');
}

// eliminate trailing white space
src = src.replace(/ +\n/g, '\n');

if (origsrc !== src) {
// write it out yo
fs.writeFileSync(file, src, 'utf8');
}
cbDone();
}
}, complete);
}, true);

0 comments on commit ce66890

Please sign in to comment.