Skip to content

Commit

Permalink
Cleaned up both build files for side-by-side comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesshore committed Sep 25, 2013
1 parent a745d60 commit 0faf584
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 120 deletions.
54 changes: 22 additions & 32 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
// Copyright (c) 2012 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.

"use strict";

var karma = require("./build/util/karma_runner.js");

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
jshint: {
browser: {
options: browserLintOptions(),
files: {
src: "src/client/**/*.js"
}
src: "src/client/**/*.js"
},
node: {
options: nodeLintOptions(),
files: {
src: ["src/*.js", "src/server/**/*.js", "build/util/**/*.js", "Gruntfile.js"]
}
src: ["src/*.js", "src/server/**/*.js", "build/util/**/*.js", "Jakefile.js", "Gruntfile.js"]
}
},

Expand All @@ -26,42 +23,35 @@ module.exports = function(grunt) {
},

karma: {
all: {
server: {
configFile: "build/config/karma.conf.js"
}
}

},

// pkg: grunt.file.readJSON('package.json'),
// uglify: {
// options: {
// banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
// },
// build: {
// src: 'src/<%= pkg.name %>.js',
// dest: 'build/<%= pkg.name %>.min.js'
// }
// }
runKarma: {
// Modify (or comment out) the following list to cause the build to fail unless these browsers are tested.
requiredBrowsers: [
"IE 8.0.0 (Windows XP)",
"IE 9.0.0 (Windows 7)",
"Firefox 23.0.0 (Mac OS X 10.8)",
"Chrome 29.0.1547 (Mac OS X 10.8.5)",
"Safari 6.0.5 (Mac OS X 10.8.5)",
"Mobile Safari 6.0.0 (iOS 6.1)"
]
}
});

// // Load the plugin that provides the "uglify" task.
// grunt.loadNpmTasks('grunt-contrib-uglify');
//
// // Default task(s).
// grunt.registerTask('default', ['uglify']);
grunt.registerTask("default", "Lint and test", ["jshint", "test"]);

grunt.registerTask("test", "Test everything", ["nodeunit", "runKarma"]);

grunt.registerTask("default", "Lint and test", ["jshint", "nodeunit"], function() {
console.log("\n\nOK");
});

grunt.registerTask("testClient", "Test browser code", function() {
karma.runTests([], this.async(), grunt.warn);
grunt.registerTask("runKarma", "Test browser code", function() {
karma.runTests(grunt.config("runKarma.requiredBrowsers"), this.async(), grunt.warn);
});

grunt.loadNpmTasks("grunt-karma");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-nodeunit");
grunt.loadNpmTasks("grunt-karma");

function globalLintOptions() {
return {
Expand Down
175 changes: 87 additions & 88 deletions Jakefile.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,103 @@
// Copyright (c) 2012 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
/*global desc, task, jake, fail, complete, directory, require, console, process */
(function () {
"use strict";
/*global desc, task, jake, fail, complete, directory*/

// Uncomment and modify the following list to cause the build to fail unless these browsers are tested.
var REQUIRED_BROWSERS = [
// "IE 8.0.0 (Windows XP)",
// "IE 9.0.0 (Windows 7)",
// "Firefox 23.0.0 (Mac OS X 10.8)",
// "Chrome 29.0.1547 (Mac OS X 10.8.5)",
// "Safari 6.0.5 (Mac OS X 10.8.5)",
// "Mobile Safari 6.0.0 (iOS 6.1)"
];
"use strict";

var lint = require("./build/util/lint_runner.js");
var nodeunit = require("./build/util/nodeunit_runner.js");
var karma = require("./build/util/karma_runner.js");
var lint = require("./build/util/lint_runner.js");
var nodeunit = require("./build/util/nodeunit_runner.js");
var karma = require("./build/util/karma_runner.js");

desc("Lint and test");
task("default", ["lint", "test"], function() {
console.log("\n\nOK");
});
// Modify (or comment out) the following list to cause the build to fail unless these browsers are tested.
var REQUIRED_BROWSERS = [
"IE 8.0.0 (Windows XP)",
"IE 9.0.0 (Windows 7)",
"Firefox 23.0.0 (Mac OS X 10.8)",
"Chrome 29.0.1547 (Mac OS X 10.8.5)",
"Safari 6.0.5 (Mac OS X 10.8.5)",
"Mobile Safari 6.0.0 (iOS 6.1)"
];

desc("Start Karma server -- run this first");
task("karma", function() {
karma.serve(complete, fail);
}, {async: true});
desc("Lint and test");
task("default", ["lint", "test"], function() {
console.log("\n\nOK");
});

desc("Lint everything");
task("lint", [], function () {
var passed = lint.validateFileList(nodeFilesToLint(), nodeLintOptions(), {});
passed = lint.validateFileList(browserFilesToLint(), browserLintOptions(), {}) && passed;
if (!passed) fail("Lint failed");
});
desc("Start Karma server -- run this first");
task("karma", function() {
karma.serve(complete, fail);
}, {async: true});

desc("Test everything");
task("test", ["testServer", "testClient"]);
desc("Lint everything");
task("lint", function () {
var passed = lint.validateFileList(nodeFilesToLint(), nodeLintOptions(), {});
passed = lint.validateFileList(browserFilesToLint(), browserLintOptions(), {}) && passed;
if (!passed) fail("Lint failed");
});

desc("Test node.js code");
task("testServer", function() {
nodeunit.runTests(nodeFilesToTest(), complete, fail);
}, {async: true});
desc("Test everything");
task("test", ["testNode", "testClient"]);

desc("Test browser code");
task("testClient", function() {
karma.runTests(REQUIRED_BROWSERS, complete, fail);
}, {async: true});
desc("Test node.js code");
task("testNode", function() {
nodeunit.runTests(nodeFilesToTest(), complete, fail);
}, {async: true});

function nodeFilesToTest() {
var testFiles = new jake.FileList();
testFiles.include("src/_*_test.js");
testFiles.include("src/server/**/_*_test.js");
var tests = testFiles.toArray();
return tests;
}
desc("Test browser code");
task("testClient", function() {
karma.runTests(REQUIRED_BROWSERS, complete, fail);
}, {async: true});

function nodeFilesToLint() {
var files = new jake.FileList();
files.include("src/*.js");
files.include("src/server/**/*.js");
files.include("build/util/**/*.js");
files.include("Jakefile.js");
return files.toArray();
}
function nodeFilesToTest() {
var testFiles = new jake.FileList();
testFiles.include("src/_*_test.js");
testFiles.include("src/server/**/_*_test.js");
var tests = testFiles.toArray();
return tests;
}

function browserFilesToLint() {
var files = new jake.FileList();
files.include("src/client/**/*.js");
return files.toArray();
}
function nodeFilesToLint() {
var files = new jake.FileList();
files.include("src/*.js");
files.include("src/server/**/*.js");
files.include("build/util/**/*.js");
files.include("Jakefile.js");
files.include("Gruntfile.js");
return files.toArray();
}

function globalLintOptions() {
return {
bitwise:true,
curly:false,
eqeqeq:true,
forin:true,
immed:true,
latedef:false,
newcap:true,
noarg:true,
noempty:true,
nonew:true,
regexp:true,
undef:true,
strict:true,
trailing:true
};
}
function browserFilesToLint() {
var files = new jake.FileList();
files.include("src/client/**/*.js");
return files.toArray();
}

function nodeLintOptions() {
var options = globalLintOptions();
options.node = true;
return options;
}
function globalLintOptions() {
return {
bitwise:true,
curly:false,
eqeqeq:true,
forin:true,
immed:true,
latedef:false,
newcap:true,
noarg:true,
noempty:true,
nonew:true,
regexp:true,
undef:true,
strict:true,
trailing:true
};
}

function browserLintOptions() {
var options = globalLintOptions();
options.browser = true;
return options;
}
function nodeLintOptions() {
var options = globalLintOptions();
options.node = true;
return options;
}

}());
function browserLintOptions() {
var options = globalLintOptions();
options.browser = true;
return options;
}

0 comments on commit 0faf584

Please sign in to comment.