Преглед на файлове

Made it possible to change the default task so it'll run accordingly without the :git prefix.

fredck преди 11 години
родител
ревизия
f5442908fa
променени са 2 файла, в които са добавени 12 реда и са изтрити 5 реда
  1. 6 3
      dev/tasks/jshint.js
  2. 6 2
      gruntfile.js

+ 6 - 3
dev/tasks/jshint.js

@@ -6,17 +6,20 @@
 var tools = require( './res/tools' );
 
 module.exports = function( grunt ) {
-	// Base task configuration, targetting "all" by default.
+	// Base task configuration, targeting "all" by default.
 	var config = {
 		all: [ '**/*.js' ],
 		options: defaultConfig
 	};
 
+	// Get information about the task being executed.
 	var isGitTask = ( grunt.cli.tasks.indexOf( 'jshint:git' ) > -1 ),
-		isDefaultTask = ( grunt.cli.tasks.indexOf( 'default' ) > -1 ) || !grunt.cli.tasks.length;
+		isDefaultTask = ( grunt.cli.tasks.indexOf( 'default' ) > -1 ) || !grunt.cli.tasks.length,
+		// Hacking grunt hard.
+		isDefaultAndGit = isDefaultTask && ( grunt.task._tasks.default.info.indexOf( '"jshint:git"' ) > -1 );
 
 	// Create the :git configuration on the fly, if necessary.
-	if ( isGitTask || isDefaultTask ) {
+	if ( isGitTask || isDefaultAndGit ) {
 		delete config.all;
 		config.git = tools.getGitDirtyFiles();
 	}

+ 6 - 2
gruntfile.js

@@ -3,6 +3,10 @@
 'use strict';
 
 module.exports = function( grunt ) {
+	// First register the "default" task, so it can be analized by other tasks.
+	grunt.registerTask( 'default', [ 'jshint:git', 'jscs' ] );
+
+	// Basic configuration, which will be overloaded by the tasks.
 	grunt.initConfig( {
 		pkg: grunt.file.readJSON( 'package.json' ),
 
@@ -19,11 +23,11 @@ module.exports = function( grunt ) {
 		}
 	} );
 
+	// Finally load the tasks.
 	grunt.loadTasks( 'dev/tasks' );
-
-	grunt.registerTask( 'default', [ 'jshint:git', 'jscs' ] );
 };
 
+// The list of files we want to exclude from linting tasks, like jshint and jscs.
 var lintIgnores = [
 	'node_modules/**',
 	'build/**'