Skip to content

Commit

Permalink
grunt cli integration
Browse files Browse the repository at this point in the history
  • Loading branch information
subeeshcbabu committed Apr 17, 2014
1 parent 5d5b506 commit 579a021
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 12 deletions.
6 changes: 3 additions & 3 deletions config/buildorch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

],
"prescript" : "",
"command" : "path:node_modules/.bin/grunt",
"command" : "path:node_modules/.bin/grunt",
"gruntcli" : "grunt-cli@~0.1.11",
"execbake" : {
"lint" : "lint",
"unittest" : "test",
"coverage" : "coverage",
"custom" : "build"
"coverage" : "coverage"
},
"postscript" : "",
"clean" : [
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';
"use strict";
//Now supporting CLI only, module based access in Progress.

17 changes: 13 additions & 4 deletions lib/baker.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ var async = require('async'),
* @param callback
*/
function execbake (options, callback) {
var gruntF = path.join(process.cwd(), 'Gruntfile.json'),
gruntf = path.join(process.cwd(), 'gruntfile.json'),
var gruntF = path.join(process.cwd(), 'Gruntfile.js'),
gruntf = path.join(process.cwd(), 'gruntfile.js'),
exists = fs.existsSync(gruntF) || fs.existsSync(gruntf);

debug('start bake : ' + JSON.stringify(options));
Expand All @@ -36,7 +36,17 @@ function execbake (options, callback) {
debug("No Grunt file");
//Override the commadn to use npm run-script
command = "npm run-script";
}
} else {
//Check if Grunt CLI is already installed or not.
if (! fs.existsSync(command)) {

var res, installVer = "npm install " + bakeConfig.gruntcli;
debug("Install Grunt CLI " + installVer);
res = shell.exec(installVer, {silent : false});

}

}

var tasks = getTasks(command, execConfig, metrics.bake);

Expand Down Expand Up @@ -66,7 +76,6 @@ function getTasks (command, execConfig, metrics) {
metrics[key] = {};
metrics[key].starttime = format(new Date());
logger.info("[ bake : " + key + ": start ]");

shell.exec( command + ' ' + execConfig[key], function (code, output){
metrics[key].endtime = format(new Date());
logger.info("[ bake : "+ key + ": end ]");
Expand Down
5 changes: 3 additions & 2 deletions lib/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,10 @@ function execTask (tasks, cb){
});

//Execute init and build
async.series(orch.steps, function (err, results) {
async.series(orch.steps, function (error, results) {

orch.loadConfig('metrics', function(err, metricsConfig){

if (!err) {
writeMetrics(metricsConfig, orch.metrics, orch.errors, function(err){
cb && cb(err);
Expand Down
153 changes: 153 additions & 0 deletions test/fixtures/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
// Whether the scan should stop on first error.
"passfail": false,
// Maximum errors before stopping.
"maxerr": 100,


// Predefined globals

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

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

// Custom predefined globals.
"predef": ["resourceRoot"],

// Development

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


// ECMAScript 5

// Whether the "use strict"; pragma should be required.
"strict": true,
// Whether global "use strict"; should be allowed (also enables strict).
"globalstrict": true,


// The Good Parts

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


// Style preferences

// Whether constructor names must be capitalized.
"newcap": false,
// Whether empty blocks should be forbidden.
"noempty": false,
// Whether using `new` for side-effects should be forbidden.
"nonew": false,
// Whether names should be checked for leading or trailing underscores
// (object._attribute would be forbidden).
"nomen": false,
// Whether only one var statement per function should be allowed.
"onevar": false,
// Whether increment and decrement (`++` and `--`) should be forbidden.
"plusplus": false,
// Whether all forms of subscript notation are allowed.
"sub": false,
// Whether trailing whitespace rules apply.
"trailing": false,
// Specify indentation.
"indent": 4,
// Whether strict whitespace rules apply.
"white": false,

// Complexity

// Maximum number of function parameters.
"maxparams": 5,
// Maximum block nesting depth.
"maxdepth": 10,
// Maximum number of statements per function.
"maxstatements": 25,
// Maximum cyclomatic complexity.
"maxcomplexity": 20
}
26 changes: 26 additions & 0 deletions test/fixtures/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var grunt = require('grunt');

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['index.js'],
options: {
jshintrc: '.jshintrc'
}
}
});

// Load the plugin that provides the "jshint" task.
grunt.loadNpmTasks('grunt-contrib-jshint');

// Default task(s).
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('test', ['jshint']);
grunt.registerTask('coverage', ['jshint']);

grunt.registerTask('default', ['test']);

};
2 changes: 1 addition & 1 deletion test/fixtures/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict'
"use strict";


4 changes: 3 additions & 1 deletion test/fixtures/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"devDependencies": {
"mocha": "~1.18.2",
"chai": "~1.9.1",
"jshint": "~2.5.0"
"jshint": "~2.5.0",
"grunt": "~0.4.4",
"grunt-contrib-jshint": "~0.10.0"
}
}

0 comments on commit 579a021

Please sign in to comment.