Browse Source

Take the ignore list for jscs and jshint from .gitignore.

fredck 11 years ago
parent
commit
2ca74332cc

+ 8 - 2
packages/ckeditor5-utils/.gitignore

@@ -1,2 +1,8 @@
-node_modules
-build
+# These files will be ignored by git and by our linting tools:
+#	grunt jshint
+#	grunt jscs
+#
+# Be sure to append /** to folders to have everything inside it ignored.
+
+node_modules/**
+build/**

+ 9 - 0
packages/ckeditor5-utils/dev/tasks/jscs.js

@@ -20,5 +20,14 @@ module.exports = function( grunt ) {
 		}
 	} );
 
+	// Take ignore list from .gitIgnore.
+	grunt.config.merge( {
+		jscs: {
+			options: {
+				excludeFiles: tools.getGitIgnore( grunt )
+			}
+		}
+	} );
+
 	grunt.loadNpmTasks( 'grunt-jscs' );
 };

+ 9 - 0
packages/ckeditor5-utils/dev/tasks/jshint.js

@@ -18,5 +18,14 @@ module.exports = function( grunt ) {
 		}
 	} );
 
+	// Take ignore list from .gitIgnore.
+	grunt.config.merge( {
+		jshint: {
+			options: {
+				ignores: tools.getGitIgnore( grunt )
+			}
+		}
+	} );
+
 	grunt.loadNpmTasks( 'grunt-contrib-jshint' );
 };

+ 20 - 1
packages/ckeditor5-utils/dev/tasks/res/tools.js

@@ -2,7 +2,8 @@
 
 'use strict';
 
-var dirtyFiles;
+var dirtyFiles,
+	ignoreList;
 
 module.exports = {
 	checkTaskInQueue: function( grunt, task ) {
@@ -46,6 +47,24 @@ module.exports = {
 		grunt.config.merge( taskConfig );
 	},
 
+	getGitIgnore: function( grunt ) {
+		if ( !ignoreList ) {
+			ignoreList = grunt.file.read( '.gitignore' );
+
+			ignoreList = ignoreList
+				// Remove comment lines.
+				.replace( /^#.*$/gm, '' )
+				// Transform into array.
+				.split( /\n+/ )
+				// Remove empty entries.
+				.filter( function( path ) {
+					return !!path;
+				} );
+		}
+
+		return ignoreList;
+	},
+
 	getGitDirtyFiles: function() {
 		// Cache it, so it is executed only once when running multiple tasks.
 		if ( !dirtyFiles ) {

+ 0 - 8
packages/ckeditor5-utils/gruntfile.js

@@ -12,13 +12,11 @@ module.exports = function( grunt ) {
 
 		jshint: {
 			options: {
-				'ignores': lintIgnores
 			}
 		},
 
 		jscs: {
 			options: {
-				'excludeFiles': lintIgnores
 			}
 		}
 	} );
@@ -26,9 +24,3 @@ module.exports = function( grunt ) {
 	// Finally load the tasks.
 	grunt.loadTasks( 'dev/tasks' );
 };
-
-// The list of files we want to exclude from linting tasks, like jshint and jscs.
-var lintIgnores = [
-	'node_modules/**',
-	'build/**'
-];