<commit_before>/*global module:false*/
module.exports = function(grunt) {

  'use strict';

  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner : '/*!\n' +
      ' * <%= pkg.name %> v<%= pkg.version %> - <%= pkg.description %>\n' +
      ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %> - <%= pkg.homepage %>\n' +
      ' * License: <%= pkg.license %>\n' +
      ' */\n\n',
      outputDir: 'dist',
      output : '<%= meta.outputDir %>/<%= pkg.name %>',
      outputMin : '<%= meta.outputDir %>/<%= pkg.name.replace("js", "min.js") %>'
    },

    rig: {
      options : {
        banner : '<%= meta.banner %>'
      },
      dist: {
        files: {
          '<%= meta.output %>' : ['src/include/wrapper.js'],
          'dist/jQuery.headroom.js' : ['src/jQuery.headroom.js'],
          'dist/angular.headroom.js' : ['src/angular.headroom.js']
        }
      }
    },

    uglify: {
      options : {
        banner : '<%= meta.banner %>',
        report: 'gzip'
      },
      dist: {
        files : {
          '<%= meta.outputMin %>'  : '<%= meta.output %>',
          'dist/jQuery.headroom.min.js': 'dist/jQuery.headroom.js',
          'dist/angular.headroom.min.js': 'dist/angular.headroom.js'
        }
      }
    },

    jshint: {
      prebuild : {
        options : {
          jshintrc : '.jshintrc'
        },
        files : {
          src : [
            'Gruntfile.js',
            'src/*.js'
          ]
        }
      },
      tests : {
        options : grunt.util._.merge(
          grunt.file.readJSON('.jshintrc'),
          grunt.file.readJSON('spec/.jshintrc')),
        files : {
          src : ['spec/*.js']
        }
      }
    },

    karma : {
      options : {
        frameworks : ['jasmine'],
        browsers : ['PhantomJS', 'Chrome', 'Opera', 'Safari', 'Firefox'],
        files : [
          'spec/helpers/polyfill.js', // PhantomJS needs Function.prototype.bind polyfill
          'src/*.js',
          'spec/*.js'
        ]
      },
      unit : {
        options : {
          background: true,
          reporters : 'dots'
        },
      },
      continuous : {
        options : {
          singleRun : true,
          browsers : ['PhantomJS']
        }
      }
    },

    watch: {
      options : {
        atBegin : true
      },
      files: [
        'src/*.js',
        'spec/*.js'
      ],
      tasks: ['prehint', 'karma:unit:run']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-rigger');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('prehint', ['jshint:prebuild', 'jshint:tests']);
  grunt.registerTask('ci', ['prehint', 'karma:continuous']);
  grunt.registerTask('dist', ['ci', 'rig', 'uglify']);
  grunt.registerTask('default', ['karma:unit:start', 'watch']);
};
<commit_msg>fix > headroom.js@0.7.0 test /Users/WickyNilliams/Repositories/headroom.js > grunt test --verbose<commit_after>/*global module:false*/
module.exports = function(grunt) {

  'use strict';

  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner : '/*!\n' +
      ' * <%= pkg.name %> v<%= pkg.version %> - <%= pkg.description %>\n' +
      ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %> - <%= pkg.homepage %>\n' +
      ' * License: <%= pkg.license %>\n' +
      ' */\n\n',
      outputDir: 'dist',
      output : '<%= meta.outputDir %>/<%= pkg.name %>',
      outputMin : '<%= meta.outputDir %>/<%= pkg.name.replace("js", "min.js") %>'
    },

    rig: {
      options : {
        banner : '<%= meta.banner %>'
      },
      dist: {
        files: {
          '<%= meta.output %>' : ['src/include/wrapper.js'],
          'dist/jQuery.headroom.js' : ['src/jQuery.headroom.js'],
          'dist/angular.headroom.js' : ['src/angular.headroom.js']
        }
      }
    },

    uglify: {
      options : {
        banner : '<%= meta.banner %>',
        report: 'gzip'
      },
      dist: {
        files : {
          '<%= meta.outputMin %>'  : '<%= meta.output %>',
          'dist/jQuery.headroom.min.js': 'dist/jQuery.headroom.js',
          'dist/angular.headroom.min.js': 'dist/angular.headroom.js'
        }
      }
    },

    jshint: {
      prebuild : {
        options : {
          jshintrc : '.jshintrc'
        },
        files : {
          src : [
            'Gruntfile.js',
            'src/*.js'
          ]
        }
      },
      tests : {
        options : grunt.util._.merge(
          grunt.file.readJSON('.jshintrc'),
          grunt.file.readJSON('spec/.jshintrc')),
        files : {
          src : ['spec/*.js']
        }
      }
    },

    karma : {
      options : {
        frameworks : ['jasmine'],
        browsers : ['PhantomJS', 'Chrome', 'Opera', 'Safari', 'Firefox'],
        files : [
          'spec/helpers/polyfill.js', // PhantomJS needs Function.prototype.bind polyfill
          'src/*.js',
          'spec/*.js'
        ]
      },
      unit : {
        options : {
          background: true,
          reporters : 'dots'
        },
      },
      continuous : {
        options : {
          singleRun : true,
          browsers : ['PhantomJS']
        }
      }
    },

    watch: {
      options : {
        atBegin : true
      },
      files: [
        'src/*.js',
        'spec/*.js'
      ],
      tasks: ['prehint', 'karma:unit:run']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-rigger');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('prehint', ['jshint:prebuild', 'jshint:tests']);
  grunt.registerTask('ci', ['prehint', 'karma:continuous']);
  grunt.registerTask('dist', ['ci', 'rig', 'uglify']);
  grunt.registerTask('test', ['karma:continuous']);
  grunt.registerTask('default', ['karma:unit:start', 'watch']);
};
<|endoftext|>


<commit_before>module.exports = function( grunt ) {

	"use strict";

	var distpaths = [
			"dist/jquery.js",
			"dist/jquery.min.js",
			"dist/jquery.min.map"
		],
		readOptionalJSON = function( filepath ) {
			var data = {};
			try {
				data = grunt.file.readJSON( filepath );
			} catch(e) {}
			return data;
		};

	grunt.initConfig({
		pkg: grunt.file.readJSON("package.json"),
		dst: readOptionalJSON("dist/.destination.json"),
		compare_size: {
			files: distpaths
		},
		selector: {
			"src/selector.js": [
				"src/sizzle-jquery.js",
				"src/sizzle/sizzle.js"
			]
		},
		build: {
			"dist/jquery.js": [
				"src/intro.js",
				"src/core.js",
				"src/callbacks.js",
				"src/deferred.js",
				"src/support.js",
				"src/data.js",
				"src/queue.js",
				"src/attributes.js",
				"src/event.js",
				"src/selector.js",
				"src/traversing.js",
				"src/manipulation.js",

				{ flag: "css", src: "src/css.js" },
				"src/serialize.js",
				{ flag: "ajax", src: "src/ajax.js" },
				{ flag: "ajax/script", src: "src/ajax/script.js", needs: ["ajax"]  },
				{ flag: "ajax/jsonp", src: "src/ajax/jsonp.js", needs: [ "ajax", "ajax/script" ]  },
				{ flag: "ajax/xhr", src: "src/ajax/xhr.js", needs: ["ajax"]  },
				{ flag: "effects", src: "src/effects.js", needs: ["css"] },
				{ flag: "offset", src: "src/offset.js", needs: ["css"] },
				{ flag: "dimensions", src: "src/dimensions.js", needs: ["css"] },
				{ flag: "deprecated", src: "src/deprecated.js" },

				"src/exports.js",
				"src/outro.js"
			]
		},

		jshint: {
			dist: {
				src: [ "dist/jquery.js" ],
				options: {
					jshintrc: "src/.jshintrc"
				}
			},
			grunt: {
				src: [ "Gruntfile.js" ],
				options: {
					jshintrc: ".jshintrc"
				}
			},
			tests: {
				// TODO: Once .jshintignore is supported, use that instead.
				// issue located here: https://github.com/gruntjs/grunt-contrib-jshint/issues/1
				src: [ "test/data/{test,testinit,testrunner}.js", "test/unit/**/*.js" ],
				options: {
					jshintrc: "test/.jshintrc"
				}
			}
		},

		testswarm: {
			tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing Sizzle".split(" ")
		},

		watch: {
			files: [ "<%= jshint.grunt.src %>", "<%= jshint.tests.src %>", "src/**/*.js" ],
			tasks: "dev"
		},

		uglify: {
			all: {
				files: {
					"dist/jquery.min.js": [ "dist/jquery.js" ]
				},
				options: {
					banner: "/*! jQuery v<%= pkg.version %> jquery.com | jquery.org/license */",
					sourceMap: "dist/jquery.min.map",
					beautify: {
						ascii_only: true
					}
				}
			}
		}
	});

	grunt.registerTask( "testswarm", function( commit, configFile ) {
		var jobName,
			testswarm = require( "testswarm" ),
			testUrls = [],
			pull = /PR-(\d+)/.exec( commit ),
			config = grunt.file.readJSON( configFile ).jquery,
			tests = grunt.config([ this.name, "tests" ]);

		if ( pull ) {
			jobName = "jQuery pull #" + pull[ 1 ] + "";
		} else {
			jobName = "jQuery commit #" + commit.substr( 0, 10 ) + "";
		}

		tests.forEach(function( test ) {
			testUrls.push( config.testUrl + commit + "/test/index.html?module=" + test );
		});

		testswarm({
			url: config.swarmUrl,
			pollInterval: 10000,
			timeout: 1000 * 60 * 30,
			done: this.async()
		}, {
			authUsername: config.authUsername,
			authToken: config.authToken,
			jobName: jobName,
			runMax: config.runMax,
			"runNames[]": tests,
			"runUrls[]": testUrls,
			"browserSets[]": config.browserSets
		});
	});

	// Build src/selector.js
	grunt.registerMultiTask( "selector", "Build src/selector.js", function() {

		var name = this.file.dest,
				files = this.file.src,
				sizzle = {
					api: grunt.file.read( files[0] ),
					src: grunt.file.read( files[1] )
				},
				compiled, parts;

		/**

			sizzle-jquery.js -> sizzle between "EXPOSE" blocks,
			replace define & window.Sizzle assignment

			// EXPOSE
			if ( typeof define === "function" && define.amd ) {
				define(function() { return Sizzle; });
			} else {
				window.Sizzle = Sizzle;
			}
			// EXPOSE

			Becomes...

			Sizzle.attr = jQuery.attr;
			jQuery.find = Sizzle;
			jQuery.expr = Sizzle.selectors;
			jQuery.expr[":"] = jQuery.expr.pseudos;
			jQuery.unique = Sizzle.uniqueSort;
			jQuery.text = Sizzle.getText;
			jQuery.isXMLDoc = Sizzle.isXML;
			jQuery.contains = Sizzle.contains;

		 */

		// Break into 3 pieces
		parts = sizzle.src.split("// EXPOSE");
		// Replace the if/else block with api
		parts[1] = sizzle.api;
		// Rejoin the pieces
		compiled = parts.join("");

		grunt.verbose.write("Injected sizzle-jquery.js into sizzle.js");

		// Write concatenated source to file
		grunt.file.write( name, compiled );

		// Fail task if errors were logged.
		if ( this.errorCount ) {
			return false;
		}

		// Otherwise, print a success message.
		grunt.log.writeln( "File '" + name + "' created." );
	});

	// Special "alias" task to make custom build creation less grawlix-y
	grunt.registerTask( "custom", function() {
		var done = this.async(),
				args = [].slice.call(arguments),
				modules = args.length ? args[0].replace(/,/g, ":") : "";

		// Translation example
		//
		//   grunt custom:+ajax,-dimensions,-effects,-offset
		//
		// Becomes:
		//
		//   grunt build:*:*:+ajax:-dimensions:-effects:-offset

		grunt.log.writeln( "Creating custom build...\n" );

		grunt.util.spawn({
			cmd: process.platform === "win32" ? "grunt.cmd" : "grunt",
			args: [ "build:*:*:" + modules, "uglify", "dist" ]
		}, function( err, result ) {
			if ( err ) {
				grunt.verbose.error();
				done( err );
				return;
			}

			grunt.log.writeln( result.stdout.replace("Done, without errors.", "") );

			done();
		});
	});

	// Special concat/build task to handle various jQuery build requirements
	//
	grunt.registerMultiTask(
		"build",
		"Concatenate source (include/exclude modules with +/- flags), embed date/version",
		function() {
			// Concat specified files.
			var compiled = "",
				modules = this.flags,
				optIn = !modules["*"],
				explicit = optIn || Object.keys(modules).length > 1,
				name = this.file.dest,
				src = this.file.srcRaw,
				deps = {},
				excluded = {},
				version = grunt.config( "pkg.version" ),
				excluder = function( flag, needsFlag ) {
					// optIn defaults implicit behavior to weak exclusion
					if ( optIn && !modules[ flag ] && !modules[ "+" + flag ] ) {
						excluded[ flag ] = false;
					}

					// explicit or inherited strong exclusion
					if ( excluded[ needsFlag ] || modules[ "-" + flag ] ) {
						excluded[ flag ] = true;

					// explicit inclusion overrides weak exclusion
					} else if ( excluded[ needsFlag ] === false &&
						( modules[ flag ] || modules[ "+" + flag ] ) ) {

						delete excluded[ needsFlag ];

						// ...all the way down
						if ( deps[ needsFlag ] ) {
							deps[ needsFlag ].forEach(function( subDep ) {
								modules[ needsFlag ] = true;
								excluder( needsFlag, subDep );
							});
						}
					}
				};

			// append commit id to version
			if ( process.env.COMMIT ) {
				version += " " + process.env.COMMIT;
			}

			// figure out which files to exclude based on these rules in this order:
			//  dependency explicit exclude
			//  > explicit exclude
			//  > explicit include
			//  > dependency implicit exclude
			//  > implicit exclude
			// examples:
			//  *                  none (implicit exclude)
			//  *:*                all (implicit include)
			//  *:*:-css           all except css and dependents (explicit > implicit)
			//  *:*:-css:+effects  same (excludes effects because explicit include is trumped by explicit exclude of dependency)
			//  *:+effects         none except effects and its dependencies (explicit include trumps implicit exclude of dependency)
			src.forEach(function( filepath ) {
				var flag = filepath.flag;

				if ( flag ) {

					excluder(flag);

					// check for dependencies
					if ( filepath.needs ) {
						deps[ flag ] = filepath.needs;
						filepath.needs.forEach(function( needsFlag ) {
							excluder( flag, needsFlag );
						});
					}
				}
			});

			// append excluded modules to version
			if ( Object.keys( excluded ).length ) {
				version += " -" + Object.keys( excluded ).join( ",-" );
				// set pkg.version to version with excludes, so minified file picks it up
				grunt.config.set( "pkg.version", version );
			}

			// conditionally concatenate source
			src.forEach(function( filepath ) {
				var flag = filepath.flag,
						specified = false,
						omit = false,
						message = "";

				if ( flag ) {
					if ( excluded[ flag ] !== undefined ) {
						message = ( "Excluding " + flag ).red;
						specified = true;
						omit = true;
					} else {
						message = ( "Including " + flag ).green;

						// If this module was actually specified by the
						// builder, then st the flag to include it in the
						// output list
						if ( modules[ "+" + flag ] ) {
							specified = true;
						}
					}

					// Only display the inclusion/exclusion list when handling
					// an explicit list.
					//
					// Additionally, only display modules that have been specified
					// by the user
					if ( explicit && specified ) {
						grunt.log.writetableln([ 27, 30 ], [
							message,
							( "(" + filepath.src + ")").grey
						]);
					}

					filepath = filepath.src;
				}

				if ( !omit ) {
					compiled += grunt.file.read( filepath );
				}
			});

			// Embed Version
			// Embed Date
			compiled = compiled.replace( /@VERSION/g, version )
				.replace( "@DATE", function () {
					var date = new Date();

					// YYYY-MM-DD
					return [
						date.getFullYear(),
						date.getMonth() + 1,
						date.getDate()
					].join( "-" );
				});

			// Write concatenated source to file
			grunt.file.write( name, compiled );

			// Fail task if errors were logged.
			if ( this.errorCount ) {
				return false;
			}

			// Otherwise, print a success message.
			grunt.log.writeln( "File '" + name + "' created." );
		});

	// Process files for distribution
	grunt.registerTask( "dist", function() {
		var flags, paths, stored;

		// Check for stored destination paths
		// ( set in dist/.destination.json )
		stored = Object.keys( grunt.config("dst") );

		// Allow command line input as well
		flags = Object.keys( this.flags );

		// Combine all output target paths
		paths = [].concat( stored, flags ).filter(function( path ) {
			return path !== "*";
		});

		// Ensure the dist files are pure ASCII
		var fs = require("fs"),
			nonascii = false;

		distpaths.forEach(function( filename ) {
			var text = fs.readFileSync( filename, "utf8" ),
			i, c;
			if ( text.length !== Buffer.byteLength( text, "utf8" ) ) {
				grunt.log.writeln( filename + ": Non-ASCII characters detected:" );
				for ( i = 0; i < text.length; i++ ) {
					c = text.charCodeAt( i );
					if ( c > 127 ) {
						grunt.log.writeln( "- position " + i + ": " + c );
						grunt.log.writeln( "-- " + text.substring( i - 20, i + 20 ) );
						nonascii = true;
						break;
					}
				}
			}

			// Modify map so that it points to files in the same folder;
			// see https://github.com/mishoo/UglifyJS2/issues/47
			if ( /\.map$/.test( filename ) ) {
				text = text.replace( /"dist\//g, "\"" );
				fs.writeFileSync( filename, text, "utf-8" );
			}

			// Optionally copy dist files to other locations
			paths.forEach(function( path ) {
				var created;

				if ( !/\/$/.test( path ) ) {
					path += "/";
				}

				created = path + filename.replace( "dist/", "" );
				grunt.file.write( created, text );
				grunt.log.writeln( "File '" + created + "' created." );
			});
		});

		return !nonascii;
	});

	// Load grunt tasks from NPM packages
	grunt.loadNpmTasks("grunt-compare-size");
	grunt.loadNpmTasks("grunt-git-authors");
	grunt.loadNpmTasks("grunt-update-submodules");
	grunt.loadNpmTasks("grunt-contrib-watch");
	grunt.loadNpmTasks("grunt-contrib-jshint");
	grunt.loadNpmTasks("grunt-contrib-uglify");

	// Default grunt
	grunt.registerTask( "default", [ "update_submodules", "selector", "build:*:*", "jshint", "uglify", "dist:*", "compare_size" ] );

	// Short list as a high frequency watch task
	grunt.registerTask( "dev", [ "selector", "build:*:*", "jshint" ] );
};
<commit_msg>Put .min.js file at the end so compare_size will work.<commit_after>module.exports = function( grunt ) {

	"use strict";

	var distpaths = [
			"dist/jquery.js",
			"dist/jquery.min.map",
			"dist/jquery.min.js"
		],
		readOptionalJSON = function( filepath ) {
			var data = {};
			try {
				data = grunt.file.readJSON( filepath );
			} catch(e) {}
			return data;
		};

	grunt.initConfig({
		pkg: grunt.file.readJSON("package.json"),
		dst: readOptionalJSON("dist/.destination.json"),
		compare_size: {
			files: distpaths
		},
		selector: {
			"src/selector.js": [
				"src/sizzle-jquery.js",
				"src/sizzle/sizzle.js"
			]
		},
		build: {
			"dist/jquery.js": [
				"src/intro.js",
				"src/core.js",
				"src/callbacks.js",
				"src/deferred.js",
				"src/support.js",
				"src/data.js",
				"src/queue.js",
				"src/attributes.js",
				"src/event.js",
				"src/selector.js",
				"src/traversing.js",
				"src/manipulation.js",

				{ flag: "css", src: "src/css.js" },
				"src/serialize.js",
				{ flag: "ajax", src: "src/ajax.js" },
				{ flag: "ajax/script", src: "src/ajax/script.js", needs: ["ajax"]  },
				{ flag: "ajax/jsonp", src: "src/ajax/jsonp.js", needs: [ "ajax", "ajax/script" ]  },
				{ flag: "ajax/xhr", src: "src/ajax/xhr.js", needs: ["ajax"]  },
				{ flag: "effects", src: "src/effects.js", needs: ["css"] },
				{ flag: "offset", src: "src/offset.js", needs: ["css"] },
				{ flag: "dimensions", src: "src/dimensions.js", needs: ["css"] },
				{ flag: "deprecated", src: "src/deprecated.js" },

				"src/exports.js",
				"src/outro.js"
			]
		},

		jshint: {
			dist: {
				src: [ "dist/jquery.js" ],
				options: {
					jshintrc: "src/.jshintrc"
				}
			},
			grunt: {
				src: [ "Gruntfile.js" ],
				options: {
					jshintrc: ".jshintrc"
				}
			},
			tests: {
				// TODO: Once .jshintignore is supported, use that instead.
				// issue located here: https://github.com/gruntjs/grunt-contrib-jshint/issues/1
				src: [ "test/data/{test,testinit,testrunner}.js", "test/unit/**/*.js" ],
				options: {
					jshintrc: "test/.jshintrc"
				}
			}
		},

		testswarm: {
			tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing Sizzle".split(" ")
		},

		watch: {
			files: [ "<%= jshint.grunt.src %>", "<%= jshint.tests.src %>", "src/**/*.js" ],
			tasks: "dev"
		},

		uglify: {
			all: {
				files: {
					"dist/jquery.min.js": [ "dist/jquery.js" ]
				},
				options: {
					banner: "/*! jQuery v<%= pkg.version %> jquery.com | jquery.org/license */",
					sourceMap: "dist/jquery.min.map",
					beautify: {
						ascii_only: true
					}
				}
			}
		}
	});

	grunt.registerTask( "testswarm", function( commit, configFile ) {
		var jobName,
			testswarm = require( "testswarm" ),
			testUrls = [],
			pull = /PR-(\d+)/.exec( commit ),
			config = grunt.file.readJSON( configFile ).jquery,
			tests = grunt.config([ this.name, "tests" ]);

		if ( pull ) {
			jobName = "jQuery pull #" + pull[ 1 ] + "";
		} else {
			jobName = "jQuery commit #" + commit.substr( 0, 10 ) + "";
		}

		tests.forEach(function( test ) {
			testUrls.push( config.testUrl + commit + "/test/index.html?module=" + test );
		});

		testswarm({
			url: config.swarmUrl,
			pollInterval: 10000,
			timeout: 1000 * 60 * 30,
			done: this.async()
		}, {
			authUsername: config.authUsername,
			authToken: config.authToken,
			jobName: jobName,
			runMax: config.runMax,
			"runNames[]": tests,
			"runUrls[]": testUrls,
			"browserSets[]": config.browserSets
		});
	});

	// Build src/selector.js
	grunt.registerMultiTask( "selector", "Build src/selector.js", function() {

		var name = this.file.dest,
				files = this.file.src,
				sizzle = {
					api: grunt.file.read( files[0] ),
					src: grunt.file.read( files[1] )
				},
				compiled, parts;

		/**

			sizzle-jquery.js -> sizzle between "EXPOSE" blocks,
			replace define & window.Sizzle assignment

			// EXPOSE
			if ( typeof define === "function" && define.amd ) {
				define(function() { return Sizzle; });
			} else {
				window.Sizzle = Sizzle;
			}
			// EXPOSE

			Becomes...

			Sizzle.attr = jQuery.attr;
			jQuery.find = Sizzle;
			jQuery.expr = Sizzle.selectors;
			jQuery.expr[":"] = jQuery.expr.pseudos;
			jQuery.unique = Sizzle.uniqueSort;
			jQuery.text = Sizzle.getText;
			jQuery.isXMLDoc = Sizzle.isXML;
			jQuery.contains = Sizzle.contains;

		 */

		// Break into 3 pieces
		parts = sizzle.src.split("// EXPOSE");
		// Replace the if/else block with api
		parts[1] = sizzle.api;
		// Rejoin the pieces
		compiled = parts.join("");

		grunt.verbose.write("Injected sizzle-jquery.js into sizzle.js");

		// Write concatenated source to file
		grunt.file.write( name, compiled );

		// Fail task if errors were logged.
		if ( this.errorCount ) {
			return false;
		}

		// Otherwise, print a success message.
		grunt.log.writeln( "File '" + name + "' created." );
	});

	// Special "alias" task to make custom build creation less grawlix-y
	grunt.registerTask( "custom", function() {
		var done = this.async(),
				args = [].slice.call(arguments),
				modules = args.length ? args[0].replace(/,/g, ":") : "";

		// Translation example
		//
		//   grunt custom:+ajax,-dimensions,-effects,-offset
		//
		// Becomes:
		//
		//   grunt build:*:*:+ajax:-dimensions:-effects:-offset

		grunt.log.writeln( "Creating custom build...\n" );

		grunt.util.spawn({
			cmd: process.platform === "win32" ? "grunt.cmd" : "grunt",
			args: [ "build:*:*:" + modules, "uglify", "dist" ]
		}, function( err, result ) {
			if ( err ) {
				grunt.verbose.error();
				done( err );
				return;
			}

			grunt.log.writeln( result.stdout.replace("Done, without errors.", "") );

			done();
		});
	});

	// Special concat/build task to handle various jQuery build requirements
	//
	grunt.registerMultiTask(
		"build",
		"Concatenate source (include/exclude modules with +/- flags), embed date/version",
		function() {
			// Concat specified files.
			var compiled = "",
				modules = this.flags,
				optIn = !modules["*"],
				explicit = optIn || Object.keys(modules).length > 1,
				name = this.file.dest,
				src = this.file.srcRaw,
				deps = {},
				excluded = {},
				version = grunt.config( "pkg.version" ),
				excluder = function( flag, needsFlag ) {
					// optIn defaults implicit behavior to weak exclusion
					if ( optIn && !modules[ flag ] && !modules[ "+" + flag ] ) {
						excluded[ flag ] = false;
					}

					// explicit or inherited strong exclusion
					if ( excluded[ needsFlag ] || modules[ "-" + flag ] ) {
						excluded[ flag ] = true;

					// explicit inclusion overrides weak exclusion
					} else if ( excluded[ needsFlag ] === false &&
						( modules[ flag ] || modules[ "+" + flag ] ) ) {

						delete excluded[ needsFlag ];

						// ...all the way down
						if ( deps[ needsFlag ] ) {
							deps[ needsFlag ].forEach(function( subDep ) {
								modules[ needsFlag ] = true;
								excluder( needsFlag, subDep );
							});
						}
					}
				};

			// append commit id to version
			if ( process.env.COMMIT ) {
				version += " " + process.env.COMMIT;
			}

			// figure out which files to exclude based on these rules in this order:
			//  dependency explicit exclude
			//  > explicit exclude
			//  > explicit include
			//  > dependency implicit exclude
			//  > implicit exclude
			// examples:
			//  *                  none (implicit exclude)
			//  *:*                all (implicit include)
			//  *:*:-css           all except css and dependents (explicit > implicit)
			//  *:*:-css:+effects  same (excludes effects because explicit include is trumped by explicit exclude of dependency)
			//  *:+effects         none except effects and its dependencies (explicit include trumps implicit exclude of dependency)
			src.forEach(function( filepath ) {
				var flag = filepath.flag;

				if ( flag ) {

					excluder(flag);

					// check for dependencies
					if ( filepath.needs ) {
						deps[ flag ] = filepath.needs;
						filepath.needs.forEach(function( needsFlag ) {
							excluder( flag, needsFlag );
						});
					}
				}
			});

			// append excluded modules to version
			if ( Object.keys( excluded ).length ) {
				version += " -" + Object.keys( excluded ).join( ",-" );
				// set pkg.version to version with excludes, so minified file picks it up
				grunt.config.set( "pkg.version", version );
			}

			// conditionally concatenate source
			src.forEach(function( filepath ) {
				var flag = filepath.flag,
						specified = false,
						omit = false,
						message = "";

				if ( flag ) {
					if ( excluded[ flag ] !== undefined ) {
						message = ( "Excluding " + flag ).red;
						specified = true;
						omit = true;
					} else {
						message = ( "Including " + flag ).green;

						// If this module was actually specified by the
						// builder, then st the flag to include it in the
						// output list
						if ( modules[ "+" + flag ] ) {
							specified = true;
						}
					}

					// Only display the inclusion/exclusion list when handling
					// an explicit list.
					//
					// Additionally, only display modules that have been specified
					// by the user
					if ( explicit && specified ) {
						grunt.log.writetableln([ 27, 30 ], [
							message,
							( "(" + filepath.src + ")").grey
						]);
					}

					filepath = filepath.src;
				}

				if ( !omit ) {
					compiled += grunt.file.read( filepath );
				}
			});

			// Embed Version
			// Embed Date
			compiled = compiled.replace( /@VERSION/g, version )
				.replace( "@DATE", function () {
					var date = new Date();

					// YYYY-MM-DD
					return [
						date.getFullYear(),
						date.getMonth() + 1,
						date.getDate()
					].join( "-" );
				});

			// Write concatenated source to file
			grunt.file.write( name, compiled );

			// Fail task if errors were logged.
			if ( this.errorCount ) {
				return false;
			}

			// Otherwise, print a success message.
			grunt.log.writeln( "File '" + name + "' created." );
		});

	// Process files for distribution
	grunt.registerTask( "dist", function() {
		var flags, paths, stored;

		// Check for stored destination paths
		// ( set in dist/.destination.json )
		stored = Object.keys( grunt.config("dst") );

		// Allow command line input as well
		flags = Object.keys( this.flags );

		// Combine all output target paths
		paths = [].concat( stored, flags ).filter(function( path ) {
			return path !== "*";
		});

		// Ensure the dist files are pure ASCII
		var fs = require("fs"),
			nonascii = false;

		distpaths.forEach(function( filename ) {
			var text = fs.readFileSync( filename, "utf8" ),
			i, c;
			if ( text.length !== Buffer.byteLength( text, "utf8" ) ) {
				grunt.log.writeln( filename + ": Non-ASCII characters detected:" );
				for ( i = 0; i < text.length; i++ ) {
					c = text.charCodeAt( i );
					if ( c > 127 ) {
						grunt.log.writeln( "- position " + i + ": " + c );
						grunt.log.writeln( "-- " + text.substring( i - 20, i + 20 ) );
						nonascii = true;
						break;
					}
				}
			}

			// Modify map so that it points to files in the same folder;
			// see https://github.com/mishoo/UglifyJS2/issues/47
			if ( /\.map$/.test( filename ) ) {
				text = text.replace( /"dist\//g, "\"" );
				fs.writeFileSync( filename, text, "utf-8" );
			}

			// Optionally copy dist files to other locations
			paths.forEach(function( path ) {
				var created;

				if ( !/\/$/.test( path ) ) {
					path += "/";
				}

				created = path + filename.replace( "dist/", "" );
				grunt.file.write( created, text );
				grunt.log.writeln( "File '" + created + "' created." );
			});
		});

		return !nonascii;
	});

	// Load grunt tasks from NPM packages
	grunt.loadNpmTasks("grunt-compare-size");
	grunt.loadNpmTasks("grunt-git-authors");
	grunt.loadNpmTasks("grunt-update-submodules");
	grunt.loadNpmTasks("grunt-contrib-watch");
	grunt.loadNpmTasks("grunt-contrib-jshint");
	grunt.loadNpmTasks("grunt-contrib-uglify");

	// Default grunt
	grunt.registerTask( "default", [ "update_submodules", "selector", "build:*:*", "jshint", "uglify", "dist:*", "compare_size" ] );

	// Short list as a high frequency watch task
	grunt.registerTask( "dev", [ "selector", "build:*:*", "jshint" ] );
};
<|endoftext|>


<commit_before>module.exports = function ( grunt ) {
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.initConfig({
		jshint: {
			src: ['client/js/**/*.js', '!client/js/dest/*.js'],
			gruntfile: ['Gruntfile.js'],
			options: {
				curly:  true,
				immed:  true,
				newcap: true,
				noarg:  true,
				sub:    true,
				boss:   true,
				eqnull: true,
				node:   true,
				undef:  true,
				globals: {
					_:       false,
					jQuery:  false,
					angular: false,
					moment:  false,
					console: false,
					$:       false,
					io:      false
				}
			}
		},
		uglify: {
			my_target: {
		      	files: {
		        	'client/js/dest/output.min.js': ['client/js/dest/built.js']
		      	}
		    }
		},
		concat: {
		    options: {
		    	separator: ';',
		    },
		    dist: {
				src: ['client/js/**/*.js', '!client/js/dest/*.js'],
		      	dest: 'client/js/dest/built.js',
		    },
		 }
	});
	grunt.registerTask('checkjs', ['jshint']);
	grunt.registerTask('minify', ['uglify']);
	grunt.registerTask('makeonefile', ['concat']);
	grunt.registerTask('makejs', ['concat', 'uglify']);
	grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
};<commit_msg>adding karma task to gruntfile<commit_after>module.exports = function ( grunt ) {
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.initConfig({
		jshint: {
			src: ['client/js/**/*.js', '!client/js/dest/*.js'],
			gruntfile: ['Gruntfile.js'],
			options: {
				curly:  true,
				immed:  true,
				newcap: true,
				noarg:  true,
				sub:    true,
				boss:   true,
				eqnull: true,
				node:   true,
				undef:  true,
				globals: {
					_:       false,
					jQuery:  false,
					angular: false,
					moment:  false,
					console: false,
					$:       false,
					io:      false
				}
			}
		},
		uglify: {
			my_target: {
		      	files: {
		        	'client/js/dest/output.min.js': ['client/js/dest/built.js']
		      	}
		    }
		},
		concat: {
		    options: {
		    	separator: ';',
		    },
		    dist: {
				src: ['client/js/**/*.js', '!client/js/dest/*.js'],
		      	dest: 'client/js/dest/built.js',
			},
		},
		karma: {
		 	unit: {
		 		options: {
		 			files: ['client/js/test/**/*.js']
		 		},
		 		browsers: ['Chrome']
		 	}
		}
	});
	grunt.registerTask('checkjs', ['jshint']);
	grunt.registerTask('minify', ['uglify']);
	grunt.registerTask('makeonefile', ['concat']);
	grunt.registerTask('makejs', ['concat', 'uglify']);
	grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
};<|endoftext|>


<commit_before>/**
 * Odnoklassniki service provider
 */

var config = require('../config'),
    utils  = require('../utils'),
    dom    = require('../dom');

var odnoklassniki = {
    counterUrl: config.protocol + '://connect.ok.ru/dk?st.cmd=extLike&ref={url}&uid={index}',
    counter: function (url, promise) {
        this.promises.push(promise);

        dom.getScript(utils.makeUrl(url, {
            index: this.promises.length - 1
        }));
    },
    promises: [],
    popupUrl: config.protocol + '://connect.ok.ru/dk?st.cmd=WidgetSharePreview&service=odnoklassniki&st.shareUrl={url}',
    popupWidth: 640,
    popupHeight: 400
};

utils.set(window, 'ODKL.updateCount', function (index, counter) {
    odnoklassniki.promises[index](counter);
});

module.exports = odnoklassniki;
<commit_msg>Update odnoklassniki.js<commit_after>/**
 * Odnoklassniki service provider
 */

var config = require('../config'),
    utils  = require('../utils'),
    dom    = require('../dom');

var odnoklassniki = {
    counterUrl: config.protocol + '://connect.ok.ru/dk?st.cmd=extLike&ref={url}&uid={index}',
    counter: function (url, promise) {
        this.promises.push(promise);

        dom.getScript(utils.makeUrl(url, {
            index: this.promises.length - 1
        }));
    },
    promises: [],
    popupUrl: config.protocol + '//connect.ok.ru/dk?st.cmd=WidgetSharePreview&service=odnoklassniki&st.shareUrl={url}',
    popupWidth: 640,
    popupHeight: 400
};

utils.set(window, 'ODKL.updateCount', function (index, counter) {
    odnoklassniki.promises[index](counter);
});

module.exports = odnoklassniki;
<|endoftext|>


<commit_before>'use strict';

var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function(connect, dir) {
    return connect.static(require('path').resolve(dir));
};

module.exports = function(grunt) {
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    var ejs = require('ejsify');

    grunt.initConfig({
        watch: {
            compass: {
                files: ['src/styles/**/*.scss'],
                tasks: ['compass']
            },
            js: {
                files: [ 'src/scripts/**/*.js'],
                tasks: 'browserify2'
            },
            index: {
                files: [ 'src/index.html'],
                tasks: 'copy:index'
            },
            assets: {
                files: [ 'src/styles/assets/*.*'],
                tasks: 'copy:assets'
            },
            options: {
                nospawn: true,
                livereload: {
                    port: LIVERELOAD_PORT
                }
            }
        },
        copy: {
            index: {
                src: 'src/index.html',
                dest: 'public/index.html'
            },
            assets: {
                files: [{
                    src: ['*.*'],
                    expand: true,
                    cwd: 'src/styles/assets/',
                    dest: 'public/styles/assets/'
                }]
            }
        },
        connect: {
            options: {
                port: 9000,
                hostname: 'localhost',
                directory: './public'

            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, './public')
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            }
        },
        browserify2: {
            dev: {
                entry: './src/scripts/app.js',
                compile: './public/scripts/app.js',
                debug: true,
                options: {
                    expose: {
                        files: [
                            {
                                cwd: 'src/scripts/',
                                src: ['**/*.ejs'],
                                dest: 'templates/'
                            },
                            {
                                cwd: 'src/scripts/views/',
                                src: ['**/*.js'],
                                dest: 'views/'
                            },
                            {
                                cwd: 'src/scripts/models/',
                                src: ['**/*.js'],
                                dest: 'models/'
                            },
                            {
                                cwd: 'src/scripts/collections/',
                                src: ['**/*.js'],
                                dest: 'collections/'
                            }
                        ]
                    }
                },
                beforeHook: function (bundle) {
                    return bundle.transform(ejs);
                }
            }
        },

        compass: {
            dev: {
                options: {
                    sassDir: 'src/styles',
                    cssDir: 'public/styles',
                    imagesDir: 'public/styles/assets/images',
                    javascriptsDir: 'public/scripts',
                    fontsDir: 'public/styles/assets/fonts',
                    environment: 'dev',
                    outputStyle: 'expanded',
                    relativeAssets: true
                }
            }
        }
    });

    grunt.registerTask('server', ['connect:livereload', 'open', 'watch']);
    grunt.registerTask('init', ['compass', 'browserify2']);

    grunt.registerTask('default', ['watch']);
};
<commit_msg>server now inits before serving<commit_after>'use strict';

var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function(connect, dir) {
    return connect.static(require('path').resolve(dir));
};

module.exports = function(grunt) {
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    var ejs = require('ejsify');

    grunt.initConfig({
        watch: {
            compass: {
                files: ['src/styles/**/*.scss'],
                tasks: ['compass']
            },
            js: {
                files: [ 'src/scripts/**/*.js'],
                tasks: 'browserify2'
            },
            index: {
                files: [ 'src/index.html'],
                tasks: 'copy:index'
            },
            assets: {
                files: [ 'src/styles/assets/*.*'],
                tasks: 'copy:assets'
            },
            options: {
                nospawn: true,
                livereload: {
                    port: LIVERELOAD_PORT
                }
            }
        },
        copy: {
            index: {
                src: 'src/index.html',
                dest: 'public/index.html'
            },
            assets: {
                files: [{
                    src: ['*.*'],
                    expand: true,
                    cwd: 'src/styles/assets/',
                    dest: 'public/styles/assets/'
                }]
            }
        },
        connect: {
            options: {
                port: 9000,
                hostname: 'localhost',
                directory: './public'

            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, './public')
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            }
        },
        browserify2: {
            dev: {
                entry: './src/scripts/app.js',
                compile: './public/scripts/app.js',
                debug: true,
                options: {
                    expose: {
                        files: [
                            {
                                cwd: 'src/scripts/',
                                src: ['**/*.ejs'],
                                dest: 'templates/'
                            },
                            {
                                cwd: 'src/scripts/views/',
                                src: ['**/*.js'],
                                dest: 'views/'
                            },
                            {
                                cwd: 'src/scripts/models/',
                                src: ['**/*.js'],
                                dest: 'models/'
                            },
                            {
                                cwd: 'src/scripts/collections/',
                                src: ['**/*.js'],
                                dest: 'collections/'
                            }
                        ]
                    }
                },
                beforeHook: function (bundle) {
                    return bundle.transform(ejs);
                }
            }
        },

        compass: {
            dev: {
                options: {
                    sassDir: 'src/styles',
                    cssDir: 'public/styles',
                    imagesDir: 'public/styles/assets/images',
                    javascriptsDir: 'public/scripts',
                    fontsDir: 'public/styles/assets/fonts',
                    environment: 'dev',
                    outputStyle: 'expanded',
                    relativeAssets: true
                }
            }
        }
    });

    grunt.registerTask('init', ['compass', 'browserify2']);
    grunt.registerTask('server', ['copy', 'init', 'connect:livereload', 'open', 'watch']);

    grunt.registerTask('default', ['watch']);
};
<|endoftext|>


<commit_before>/*
 * grunt-iron-worker
 *
 * Copyright (c) 2013 Eric Kryski.
 * MIT Licensed
 */

'use strict';

module.exports = function(grunt) {

  // TODO: Update the task to use node-ironio or ruby gem CLI
  var exec = require('child_process').exec;
  var path = require('path');

  var optionsMapping = {
    payloadFile: '--payload-file',
    payload: '--payload',
    projectId: '--project-id',
    environment: '--env',
    name: '--name',
    concurrency: '--max-concurrency',
    retries: '--retries',
    retriesDelay: '--retries-delay',
    host: '--host',
    async: '--async',
    fullRemoteBuild: '--full-remote-build',
    priority: '--priority',
    timeout: '--timeout',
    delay: '--delay',
    start: '--start-at',
    end: '--end-at',
	workerConfig: '--worker-config',
    runTimes: '--run-times',
    runEvery: '--run-every'
  };

  function generateOptionsString(target, options, data){
    var string = [];
    var key;

    for (key in options){
      // Skip payload and payload file options for upload targets
      if (target === 'upload' && (key === 'payloadFile' || key === 'payload')){
        continue;
      }

      if (optionsMapping[key]) {
        string.push(optionsMapping[key]);
      }

      if (optionsMapping[key] || key === 'worker') {

        // Need to remove '.worker' extension for scheduling
        if (target === 'schedule' && key === 'worker'){
          options[key] = options[key].split('.')[0];
        }
        string.push(options[key]);
      }
    }

    for (key in data){
      if (optionsMapping[key]) {
        if (data[key] || data[key] === 0){
          string.push(optionsMapping[key]);
        }

        // async and full remote build are just flags, they have no values
        if (key !== 'async' && key !== 'fullRemoteBuild'){

          // If it is a date convert it to ISO string format
          // and wrap in quotes. Like so "2013-04-03T20:00:00.000Z"
          if (key === 'start' || key === 'end'){
            var date = new Date(data[key]);
            data[key] = '"' + date.toISOString() + '"';
          }

          string.push(data[key]);
        }
      }
    }

    return string.join(' ');
  }

  grunt.registerMultiTask('ironworker', 'Grunt iron_worker interface', function() {
    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({});
    var callback = this.async();

	var target = this.target;
	var data = this.data;

	if(this.args.length > 0){
		target = this.args[0];
		data = this.data[target];
	}

    grunt.verbose.writeflags(options, 'Options');

    var cmd = grunt.template.process(['iron_worker', target, generateOptionsString(target, options, data)].join(' '));

    grunt.verbose.writeln('Command:', cmd.yellow);

    var worker = exec(cmd, function (err, stdout, stderr) {
      if (err) grunt.warn(err);

      callback();
    });

    worker.stdout.pipe(process.stdout);
    worker.stderr.pipe(process.stderr);
  });
};
<commit_msg>wrong file<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      files: '<config:lint.files>',
      tasks: 'default'
    },

    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        node: true,
        es5: true,
        globals: {}
      },

      files: ['grunt.js', 'tasks/**/*.js']
    }
  });

  // Load local tasks.
  grunt.loadTasks('tasks');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  // Default task.
  grunt.registerTask('default', 'jshint');
};
<|endoftext|>


<commit_before>/*
 * grunt-draw-my-project
 * http://manland.github.io/draw-my-project
 *
 * Copyright (c) 2014 Romain Maneschi
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  var gruntConfig = require( './gruntConfig.js' );

  var taskConfig = {
    pkg: grunt.file.readJSON("package.json"),
    meta: {
      banner:
        '/**\n' +
        ' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * <%= pkg.homepage %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> : <%= pkg.author.url %>\n' +
        ' * Licensed <%= pkg.licenses[0].type %> <%= pkg.licenses[0].url %>\n' +
        ' */\n'
    },

    nodeunit: {
      tests: ['test/*_test.js'],
    },

    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= app_files.js %>',
        '<%= test_files.js %>',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: [
      'tmp',
      '<%= build_dir %>',
      '<%= compile_dir %>'
    ],

    copy: {
      build: {
        files: [
          {
            src: [
              '<%= app_files.js %>',
              '<%= app_files.tplHtml %>',
              '<%= vendor_files.js %>',
              '<%= vendor_files.css %>',
              '<%= app_files.assets %>',
              '<%= app_files.stylesheet %>'
            ],
            dest: '<%= build_dir %>/',
            cwd: '.',
            expand: true
          }
        ]
      },
      compile: {
        files: [
          {
            src: [ '**/*' ],
            dest: '<%= compile_dir %>/assets',
            cwd: '<%= build_dir %>/template_src/assets',
            expand: true
          }
        ]
      }
    },

    concat: {
      compile_js: {
        options: {
          banner: '<%= meta.banner %>'
        },
        src: [
          '<%= vendor_files.js %>',
          '<%= build_dir %>/template_src/src/**/*.js'
        ],
        dest: '<%= compile_dir %>/<%= pkg.name %>-<%= pkg.version %>.js'
      },
      compile_css: {
        options: {
          banner: '<%= meta.banner %>'
        },
        src: [
          'template_src/stylesheet/reset.css',
          '<%= vendor_files.css %>',
          '<%= app_files.stylesheet %>',
        ],
        dest: '<%= compile_dir %>/stylesheet/<%= pkg.name %>-<%= pkg.version %>.css'
      }
    },

    cssmin: {
      minify: {
        src: ['<%= compile_dir %>/stylesheet/<%= pkg.name %>-<%= pkg.version %>.css'],
        dest: '<%= compile_dir %>/stylesheet/<%= pkg.name %>-<%= pkg.version %>.css'
      }
    },

    uglify: {
      compile: {
        options: {
          banner: '<%= meta.banner %>'
        },
        files: {
          '<%= concat.compile_js.dest %>': '<%= concat.compile_js.dest %>'
        }
      }
    },

    index: {
      build: {
        dir: '<%= build_dir %>/template_src',
        src: [
          '<%= vendor_files.js %>',
          '<%= app_files.js %>',
          '<%= build_dir %>/**/*.css'
        ]
      },
      compile: {
        dir: '<%= compile_dir %>',
        src: [
          '<%= concat.compile_js.dest %>',
          '<%= concat.compile_css.dest %>'
        ]
      }
    },

    watch: {
      files: [
        'tasks/**/*.js',
        '<%= app_files.html %>',
        '<%= app_files.js %>',
        '<%= app_files.tplHtml %>',
        '<%= vendor_files.js %>',
        '<%= app_files.assets %>',
        '<%= app_files.stylesheet %>',
        '<%= test_files.js %>'
      ],
      tasks: ['jshint', /*'karma:build:run',*/ 'build']
    },

    ngtemplates: {
      app: {
        src: 'src/**/*.tpl.html',
        cwd: 'template_src/',
        dest: '<%= build_dir %>/template_src/src/templates.js'
      }
    },

    // Configuration to be run (and then tested).
    draw_my_project: {
      options: {
        //templateFiles: ['template/d3.html', 'template/d3.js', 'template/d3.css']
        templateFiles: [
          'template/**/*'
        ]
      },
      simple: {
        options: {
          nbNodeByFile: 3,
          advices: {
            filenameChecker: false
          },
          source: {
            srcInCode: true
          }
        },
        files: {
          'tmp/simple': ['test/fixtures/simple.js']
        }
      },
      complexe: {
        options: {
          advices: false,
          source: false
        },
        files: {
          'tmp/complexe': ['test/fixtures/complexe/**/*.js']
        }
      },
      skimbo: {
        options: {
          title: 'Skimbo',
          description: 'Manage your social life !',
          link: 'http://blog.skimbo.fr',
          favicon: 'assets/img/skimbo.png',
          urlLogo: 'assets/img/skimbo.png',
          advices: {
            filenameChecker: {
              prefix: {
                'directive': 'skim'
              },
              suffix: {
                'controller': 'Controller'
              }
            },
            notUsed: {
              desableNodeType: ['filter', 'directive']
            }
          }
        },
        files: {
          'tmp/skimbo': ['test/fixtures/skimbo/**/*.js']
        }
      },
      sturvive: {
        options: {
          title: 'Sturvive',
          description: 'A starship survivor 3d game.',
          link: 'http://manland.github.io/sturvive/',
          favicon: 'assets/img/sturvive.png',
          urlLogo: 'assets/img/sturvive.png',
          type: 'requirejs'
        },
        files: {
          'tmp/sturvive': ['test/fixtures/sturvive/**/*.js']
        }
      },
      goo: {
        options: {
          title: 'Goo Engine',
          description: 'A js lib to make 3D.',
          link: 'http://www.gootechnologies.com/',
          favicon: 'assets/img/goo.png',
          urlLogo: 'assets/img/goo.png',
          type: 'requirejs',
          //source: false,
          advices: {
            fileClassName: false,
            tooInjectDependencies: false
          },
          nbNodeByFile: -1
        },
        files: {
          'tmp/goo': ['test/fixtures/goo-require.js']
        }
      },
      timeChecking: {
        options: {
          type: 'nodejs',
          source: false
        },
        files: {
          'tmp/timeChecking': ['test/fixtures/timeChecking/**/*.js']
        }
      },
      angularApp: {
        options: {
          title: 'Angular App',
          description: 'Reference application for AngularJS',
          link: 'https://github.com/angular-app/angular-app',
          favicon: 'assets/img/angularApp.png',
          urlLogo: 'assets/img/angularApp.png',
          nbNodeByFile: -1,
          advices: {
            fileClassName: false,
            filenameChecker: {
              suffix: {
                'controller': 'Ctrl'
              }
            },
          },
        },
        files: {
          'tmp/angularApp': ['test/fixtures/angularApp/**/*.js']
        }
      },
      plotsManager: {
        options: {
          title: 'My plots',
          type: 'java',
          advices: false
        },
        files: {
          'tmp/plotsManager': ['test/fixtures/plotsManager/src/main/java/**/*.java']
        }
      }

    }

  };

  grunt.loadTasks('tasks');

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-angular-templates');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  //TODO : mincss, minhtml, angularjstpl2js

  grunt.initConfig(grunt.util._.extend(taskConfig, gruntConfig));

  grunt.registerTask('test', ['draw_my_project', 'nodeunit']);
  grunt.registerTask('build', ['clean', 'copy:build', 'index:build', 'test']);
  grunt.registerTask('dev', ['jshint', 'build', 'watch']);
  grunt.registerTask('compile', ['jshint', 'build', 'ngtemplates', 'concat:compile_js', 'concat:compile_css', 'cssmin', 'copy:compile', 'uglify:compile', 'index:compile', 'test']);
  grunt.registerTask('default', ['jshint', 'test']);

  grunt.registerMultiTask( 'index', 'Process index.html template', function () {
    var dirRE = new RegExp( '^('+this.data.dir+')\/', 'g' );

    function filterForJS ( files ) {
      return files.filter( function ( file ) {
        return file.match( /\.js$/ );
      });
    }

    function filterForCSS ( files ) {
      return files.filter( function ( file ) {
        return file.match( /\.css$/ );
      });
    }

    var jsFiles = filterForJS( this.filesSrc ).map( function ( file ) {
      return file.replace('template_src/', '').replace( dirRE, '' );
    });

    var cssFiles = filterForCSS( this.filesSrc ).map( function ( file ) {
      return file.replace( dirRE, '' );
    });

    var index = -1;
    for(var i=0, len=cssFiles.length; i<len && index === -1; i++) {
      if(cssFiles[i] === 'stylesheet/reset.css') {
        index = i;
      }
    }
    if(index > -1) {
      cssFiles.splice(index, 1);
      cssFiles.splice(0, 0, 'stylesheet/reset.css');
    }

    grunt.file.copy('template_src/index.tpl.html', this.data.dir + '/index.html', {
      process: function ( contents, path ) {
        return grunt.template.process( contents, {
          data: {
            scripts: jsFiles,
            styles: cssFiles,
            nojs_sentence: grunt.config('nojs_sentence')
          }
        });
      }
    });
  });

};
<commit_msg>add name to all tests (easy debug)<commit_after>/*
 * grunt-draw-my-project
 * http://manland.github.io/draw-my-project
 *
 * Copyright (c) 2014 Romain Maneschi
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  var gruntConfig = require( './gruntConfig.js' );

  var taskConfig = {
    pkg: grunt.file.readJSON("package.json"),
    meta: {
      banner:
        '/**\n' +
        ' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * <%= pkg.homepage %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> : <%= pkg.author.url %>\n' +
        ' * Licensed <%= pkg.licenses[0].type %> <%= pkg.licenses[0].url %>\n' +
        ' */\n'
    },

    nodeunit: {
      tests: ['test/*_test.js'],
    },

    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= app_files.js %>',
        '<%= test_files.js %>',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: [
      'tmp',
      '<%= build_dir %>',
      '<%= compile_dir %>'
    ],

    copy: {
      build: {
        files: [
          {
            src: [
              '<%= app_files.js %>',
              '<%= app_files.tplHtml %>',
              '<%= vendor_files.js %>',
              '<%= vendor_files.css %>',
              '<%= app_files.assets %>',
              '<%= app_files.stylesheet %>'
            ],
            dest: '<%= build_dir %>/',
            cwd: '.',
            expand: true
          }
        ]
      },
      compile: {
        files: [
          {
            src: [ '**/*' ],
            dest: '<%= compile_dir %>/assets',
            cwd: '<%= build_dir %>/template_src/assets',
            expand: true
          }
        ]
      }
    },

    concat: {
      compile_js: {
        options: {
          banner: '<%= meta.banner %>'
        },
        src: [
          '<%= vendor_files.js %>',
          '<%= build_dir %>/template_src/src/**/*.js'
        ],
        dest: '<%= compile_dir %>/<%= pkg.name %>-<%= pkg.version %>.js'
      },
      compile_css: {
        options: {
          banner: '<%= meta.banner %>'
        },
        src: [
          'template_src/stylesheet/reset.css',
          '<%= vendor_files.css %>',
          '<%= app_files.stylesheet %>',
        ],
        dest: '<%= compile_dir %>/stylesheet/<%= pkg.name %>-<%= pkg.version %>.css'
      }
    },

    cssmin: {
      minify: {
        src: ['<%= compile_dir %>/stylesheet/<%= pkg.name %>-<%= pkg.version %>.css'],
        dest: '<%= compile_dir %>/stylesheet/<%= pkg.name %>-<%= pkg.version %>.css'
      }
    },

    uglify: {
      compile: {
        options: {
          banner: '<%= meta.banner %>'
        },
        files: {
          '<%= concat.compile_js.dest %>': '<%= concat.compile_js.dest %>'
        }
      }
    },

    index: {
      build: {
        dir: '<%= build_dir %>/template_src',
        src: [
          '<%= vendor_files.js %>',
          '<%= app_files.js %>',
          '<%= build_dir %>/**/*.css'
        ]
      },
      compile: {
        dir: '<%= compile_dir %>',
        src: [
          '<%= concat.compile_js.dest %>',
          '<%= concat.compile_css.dest %>'
        ]
      }
    },

    watch: {
      files: [
        'tasks/**/*.js',
        '<%= app_files.html %>',
        '<%= app_files.js %>',
        '<%= app_files.tplHtml %>',
        '<%= vendor_files.js %>',
        '<%= app_files.assets %>',
        '<%= app_files.stylesheet %>',
        '<%= test_files.js %>'
      ],
      tasks: ['jshint', /*'karma:build:run',*/ 'build']
    },

    ngtemplates: {
      app: {
        src: 'src/**/*.tpl.html',
        cwd: 'template_src/',
        dest: '<%= build_dir %>/template_src/src/templates.js'
      }
    },

    // Configuration to be run (and then tested).
    draw_my_project: {
      options: {
        //templateFiles: ['template/d3.html', 'template/d3.js', 'template/d3.css']
        templateFiles: [
          'template/**/*'
        ]
      },
      simple: {
        options: {
          title: 'simple',
          nbNodeByFile: 3,
          advices: {
            filenameChecker: false
          },
          source: {
            srcInCode: true
          }
        },
        files: {
          'tmp/simple': ['test/fixtures/simple.js']
        }
      },
      complexe: {
        options: {
          title: 'complexe',
          advices: false,
          source: false
        },
        files: {
          'tmp/complexe': ['test/fixtures/complexe/**/*.js']
        }
      },
      skimbo: {
        options: {
          title: 'Skimbo',
          description: 'Manage your social life !',
          link: 'http://blog.skimbo.fr',
          favicon: 'assets/img/skimbo.png',
          urlLogo: 'assets/img/skimbo.png',
          advices: {
            filenameChecker: {
              prefix: {
                'directive': 'skim'
              },
              suffix: {
                'controller': 'Controller'
              }
            },
            notUsed: {
              desableNodeType: ['filter', 'directive']
            }
          }
        },
        files: {
          'tmp/skimbo': ['test/fixtures/skimbo/**/*.js']
        }
      },
      sturvive: {
        options: {
          title: 'Sturvive',
          description: 'A starship survivor 3d game.',
          link: 'http://manland.github.io/sturvive/',
          favicon: 'assets/img/sturvive.png',
          urlLogo: 'assets/img/sturvive.png',
          type: 'requirejs'
        },
        files: {
          'tmp/sturvive': ['test/fixtures/sturvive/**/*.js']
        }
      },
      goo: {
        options: {
          title: 'Goo Engine',
          description: 'A js lib to make 3D.',
          link: 'http://www.gootechnologies.com/',
          favicon: 'assets/img/goo.png',
          urlLogo: 'assets/img/goo.png',
          type: 'requirejs',
          //source: false,
          advices: {
            fileClassName: false,
            tooInjectDependencies: false
          },
          nbNodeByFile: -1
        },
        files: {
          'tmp/goo': ['test/fixtures/goo-require.js']
        }
      },
      timeChecking: {
        options: {
          title: 'timeChecking',
          type: 'nodejs',
          source: false
        },
        files: {
          'tmp/timeChecking': ['test/fixtures/timeChecking/**/*.js']
        }
      },
      angularApp: {
        options: {
          title: 'Angular App',
          description: 'Reference application for AngularJS',
          link: 'https://github.com/angular-app/angular-app',
          favicon: 'assets/img/angularApp.png',
          urlLogo: 'assets/img/angularApp.png',
          nbNodeByFile: -1,
          advices: {
            fileClassName: false,
            filenameChecker: {
              suffix: {
                'controller': 'Ctrl'
              }
            },
          },
        },
        files: {
          'tmp/angularApp': ['test/fixtures/angularApp/**/*.js']
        }
      },
      plotsManager: {
        options: {
          title: 'My plots',
          type: 'java',
          advices: false
        },
        files: {
          'tmp/plotsManager': ['test/fixtures/plotsManager/src/main/java/**/*.java']
        }
      }

    }

  };

  grunt.loadTasks('tasks');

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-angular-templates');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  //TODO : mincss, minhtml, angularjstpl2js

  grunt.initConfig(grunt.util._.extend(taskConfig, gruntConfig));

  grunt.registerTask('test', ['draw_my_project', 'nodeunit']);
  grunt.registerTask('build', ['clean', 'copy:build', 'index:build', 'test']);
  grunt.registerTask('dev', ['jshint', 'build', 'watch']);
  grunt.registerTask('compile', ['jshint', 'build', 'ngtemplates', 'concat:compile_js', 'concat:compile_css', 'cssmin', 'copy:compile', 'uglify:compile', 'index:compile', 'test']);
  grunt.registerTask('default', ['jshint', 'test']);

  grunt.registerMultiTask( 'index', 'Process index.html template', function () {
    var dirRE = new RegExp( '^('+this.data.dir+')\/', 'g' );

    function filterForJS ( files ) {
      return files.filter( function ( file ) {
        return file.match( /\.js$/ );
      });
    }

    function filterForCSS ( files ) {
      return files.filter( function ( file ) {
        return file.match( /\.css$/ );
      });
    }

    var jsFiles = filterForJS( this.filesSrc ).map( function ( file ) {
      return file.replace('template_src/', '').replace( dirRE, '' );
    });

    var cssFiles = filterForCSS( this.filesSrc ).map( function ( file ) {
      return file.replace( dirRE, '' );
    });

    var index = -1;
    for(var i=0, len=cssFiles.length; i<len && index === -1; i++) {
      if(cssFiles[i] === 'stylesheet/reset.css') {
        index = i;
      }
    }
    if(index > -1) {
      cssFiles.splice(index, 1);
      cssFiles.splice(0, 0, 'stylesheet/reset.css');
    }

    grunt.file.copy('template_src/index.tpl.html', this.data.dir + '/index.html', {
      process: function ( contents, path ) {
        return grunt.template.process( contents, {
          data: {
            scripts: jsFiles,
            styles: cssFiles,
            nojs_sentence: grunt.config('nojs_sentence')
          }
        });
      }
    });
  });

};
<|endoftext|>