Permalink
Browse files

Build: Add esformatter and format build files

Closes gh-8079
  • Loading branch information...
1 parent 62a1e78 commit 6b9b2abebe60edddc9364551a27ef41dfc2eda88 @arschmitz arschmitz committed Apr 16, 2015
View
@@ -1,56 +1,56 @@
module.exports = function( grunt ) {
- "use strict";
+"use strict";
- var path = require( "path" );
- var dist = "dist" + path.sep;
- var today = grunt.template.today( "UTC:yyyy" );
+var path = require( "path" );
+var dist = "dist" + path.sep;
+var today = grunt.template.today( "UTC:yyyy" );
- require( "load-grunt-config" )( grunt, {
- configPath: [
- path.join( process.cwd(), "build/tasks/options" ),
- path.join( process.cwd(), "build/tasks" )
- ],
- init: true,
- data: {
- pkg: grunt.file.readJSON( "package.json" ),
+require( "load-grunt-config" )( grunt, {
+ configPath: [
+ path.join( process.cwd(), "build/tasks/options" ),
+ path.join( process.cwd(), "build/tasks" )
+ ],
+ init: true,
+ data: {
+ pkg: grunt.file.readJSON( "package.json" ),
+ dist: dist,
+ name: "jquery.mobile",
+ phpPort: Math.floor( 8000 + Math.random() * 1000 ),
+ versionSuffix: "",
+ headHash: "",
+ headShortHash: "",
+ version: "<%= version %>",
+ dirs: {
dist: dist,
- name: "jquery.mobile",
- phpPort: Math.floor( 8000 + Math.random() * 1000 ),
- versionSuffix: "",
- headHash: "",
- headShortHash: "",
- version: "<%= version %>",
- dirs: {
- dist: dist,
- cdn: {
- google: path.join( dist, "cdn-google" ),
- jquery: path.join( dist, "cdn" ),
- git: path.join( dist, "git" )
- },
- tmp: path.join( dist, "tmp" )
+ cdn: {
+ google: path.join( dist, "cdn-google" ),
+ jquery: path.join( dist, "cdn" ),
+ git: path.join( dist, "git" )
},
- banner: [
- "/*!",
- "* jQuery Mobile <%= version %>",
- "* <%if ( headHash ) {%>Git HEAD hash: <%= headHash %> <> <% } %>Date: " +
- grunt.template.today( "UTC:ddd mmm d yyyy HH:MM:ss Z" ),
- "* http://jquerymobile.com",
- "*",
- "* Copyright 2010, " + today + " jQuery Foundation, Inc. and other" +
- " contributors",
- "* Released under the MIT license.",
- "* http://jquery.org/license",
- "*",
- "*/",
- "",
- "",
- ""
- ].join( grunt.util.linefeed ),
+ tmp: path.join( dist, "tmp" )
+ },
+ banner: [
+ "/*!",
+ "* jQuery Mobile <%= version %>",
+ "* <%if ( headHash ) {%>Git HEAD hash: <%= headHash %> <> <% } %>Date: " +
+ grunt.template.today( "UTC:ddd mmm d yyyy HH:MM:ss Z" ),
+ "* http://jquerymobile.com",
+ "*",
+ "* Copyright 2010, " + today + " jQuery Foundation, Inc. and other" +
+ " contributors",
+ "* Released under the MIT license.",
+ "* http://jquery.org/license",
+ "*",
+ "*/",
+ "",
+ "",
+ ""
+ ].join( grunt.util.linefeed ),
- bannerMin: "/*! jQuery Mobile <%= version %> | <%if ( headShortHash ) {%>Git HEAD" +
+ bannerMin: "/*! jQuery Mobile <%= version %> | <%if ( headShortHash ) {%>Git HEAD" +
"hash: <%= headShortHash %> <> <% } %>" + grunt.template.today( "UTC:yyyy-mm-dd" ) +
"T" + grunt.template.today( "UTC:HH:MM:ss" ) + "Z | (c) 2010, " +
today + " jQuery Foundation, Inc. | jquery.org/license */\n"
- }
- } );
+ }
+} );
};
View
@@ -1,128 +1,128 @@
module.exports = function( grunt ) {
- var path = require( "path" );
- var _ = require( "underscore" );
- var files = {
- css: {
- structure: {
- src: "css/structure/jquery.mobile.structure.css",
- unminified: "<%= name %>.structure<%= versionSuffix %>.css"
- },
- theme: {
- src: "css/themes/default/jquery.mobile.theme.css",
- unminified: "<%= name %>.theme<%= versionSuffix %>.css"
- },
- bundle: {
- src: "css/themes/default/jquery.mobile.css",
- unminified: "<%= name %><%= versionSuffix %>.css"
- },
- inlinesvg: {
- src: "css/themes/default/jquery.mobile.inline-svg.css",
- unminified: "<%= name %>.inline-svg<%= versionSuffix %>.css"
- },
- inlinepng: {
- src: "css/themes/default/jquery.mobile.inline-png.css",
- unminified: "<%= name %>.inline-png<%= versionSuffix %>.css"
- },
- externalpng: {
- src: "css/themes/default/jquery.mobile.external-png.css",
- unminified: "<%= name %>.external-png<%= versionSuffix %>.css"
- },
- icons: {
- src: "css/themes/default/jquery.mobile.icons.css",
- unminified: "<%= name %>.icons<%= versionSuffix %>.css"
- }
- },
- getCSSFiles: function( destDir ) {
- destDir = destDir || ".";
- var list = [];
- _.values( files.css ).forEach( function( value ) {
- list.push( {
- src: value.src,
- dest: path.join( destDir, value.unminified )
- } );
- } );
- return list;
- },
- getMinifiedCSSFiles: function( destDir ) {
- destDir = destDir || ".";
- var list = [];
- _.values( files.css ).forEach( function( value ) {
- list.push( {
- src: path.join( destDir, value.unminified ),
- dest: path.join( destDir, value.minified )
- } );
- } );
- return list;
- },
- cdn: [
- "<%= name %><%= versionSuffix %>.js",
- "<%= name %><%= versionSuffix %>.min.js",
- "<%= name %><%= versionSuffix %>.min.map",
+var path = require( "path" );
+var _ = require( "underscore" );
+var files = {
+ css: {
+ structure: {
+ src: "css/structure/jquery.mobile.structure.css",
+ unminified: "<%= name %>.structure<%= versionSuffix %>.css"
+ },
+ theme: {
+ src: "css/themes/default/jquery.mobile.theme.css",
+ unminified: "<%= name %>.theme<%= versionSuffix %>.css"
+ },
+ bundle: {
+ src: "css/themes/default/jquery.mobile.css",
+ unminified: "<%= name %><%= versionSuffix %>.css"
+ },
+ inlinesvg: {
+ src: "css/themes/default/jquery.mobile.inline-svg.css",
+ unminified: "<%= name %>.inline-svg<%= versionSuffix %>.css"
+ },
+ inlinepng: {
+ src: "css/themes/default/jquery.mobile.inline-png.css",
+ unminified: "<%= name %>.inline-png<%= versionSuffix %>.css"
+ },
+ externalpng: {
+ src: "css/themes/default/jquery.mobile.external-png.css",
+ unminified: "<%= name %>.external-png<%= versionSuffix %>.css"
+ },
+ icons: {
+ src: "css/themes/default/jquery.mobile.icons.css",
+ unminified: "<%= name %>.icons<%= versionSuffix %>.css"
+ }
+ },
+ getCSSFiles: function( destDir ) {
+ destDir = destDir || ".";
+ var list = [];
+ _.values( files.css ).forEach( function( value ) {
+ list.push( {
+ src: value.src,
+ dest: path.join( destDir, value.unminified )
+ } );
+ } );
+ return list;
+ },
+ getMinifiedCSSFiles: function( destDir ) {
+ destDir = destDir || ".";
+ var list = [];
+ _.values( files.css ).forEach( function( value ) {
+ list.push( {
+ src: path.join( destDir, value.unminified ),
+ dest: path.join( destDir, value.minified )
+ } );
+ } );
+ return list;
+ },
+ cdn: [
+ "<%= name %><%= versionSuffix %>.js",
+ "<%= name %><%= versionSuffix %>.min.js",
+ "<%= name %><%= versionSuffix %>.min.map",
- "<%= files.css.structure.unminified %>",
- "<%= files.css.structure.minified %>",
- "<%= files.css.bundle.unminified %>",
- "<%= files.css.bundle.minified %>",
- "<%= files.css.inlinesvg.unminified %>",
- "<%= files.css.inlinesvg.minified %>",
- "<%= files.css.inlinepng.unminified %>",
- "<%= files.css.inlinepng.minified %>",
- "<%= files.css.externalpng.unminified %>",
- "<%= files.css.externalpng.minified %>",
- "<%= files.css.icons.unminified %>",
- "<%= files.css.icons.minified %>",
+ "<%= files.css.structure.unminified %>",
+ "<%= files.css.structure.minified %>",
+ "<%= files.css.bundle.unminified %>",
+ "<%= files.css.bundle.minified %>",
+ "<%= files.css.inlinesvg.unminified %>",
+ "<%= files.css.inlinesvg.minified %>",
+ "<%= files.css.inlinepng.unminified %>",
+ "<%= files.css.inlinepng.minified %>",
+ "<%= files.css.externalpng.unminified %>",
+ "<%= files.css.externalpng.minified %>",
+ "<%= files.css.icons.unminified %>",
+ "<%= files.css.icons.minified %>",
- "images/*.*",
- "images/icons-png/**"
- ],
+ "images/*.*",
+ "images/icons-png/**"
+ ],
- zipFileName: "<%= name %><%= versionSuffix %>.zip",
+ zipFileName: "<%= name %><%= versionSuffix %>.zip",
- distZipOut: path.join( "<%= dist %>", "<%= name %><%= versionSuffix %>.zip" ),
+ distZipOut: path.join( "<%= dist %>", "<%= name %><%= versionSuffix %>.zip" ),
- imagesZipOut: path.join( "<%= dist %>", "<%= name %>.images<%= versionSuffix %>.zip" )
+ imagesZipOut: path.join( "<%= dist %>", "<%= name %>.images<%= versionSuffix %>.zip" )
- };
+};
- // Add minified property to files.css.*
- _.forEach( files.css, function( o ) {
- o.minified = o.unminified.replace( /\.css$/, ".min.css" );
- } );
+// Add minified property to files.css.*
+_.forEach( files.css, function( o ) {
+ o.minified = o.unminified.replace( /\.css$/, ".min.css" );
+} );
- files.cdn = [
- "<%= name %><%= versionSuffix %>.js",
- "<%= name %><%= versionSuffix %>.min.js",
- "<%= name %><%= versionSuffix %>.min.map",
+files.cdn = [
+ "<%= name %><%= versionSuffix %>.js",
+ "<%= name %><%= versionSuffix %>.min.js",
+ "<%= name %><%= versionSuffix %>.min.map",
- files.css.structure.unminified,
- files.css.structure.minified,
- files.css.bundle.unminified,
- files.css.bundle.minified,
- files.css.inlinesvg.unminified,
- files.css.inlinesvg.minified,
- files.css.inlinepng.unminified,
- files.css.inlinepng.minified,
- files.css.externalpng.unminified,
- files.css.externalpng.minified,
- files.css.icons.unminified,
- files.css.icons.minified,
+ files.css.structure.unminified,
+ files.css.structure.minified,
+ files.css.bundle.unminified,
+ files.css.bundle.minified,
+ files.css.inlinesvg.unminified,
+ files.css.inlinesvg.minified,
+ files.css.inlinepng.unminified,
+ files.css.inlinepng.minified,
+ files.css.externalpng.unminified,
+ files.css.externalpng.minified,
+ files.css.icons.unminified,
+ files.css.icons.minified,
- "images/*.*",
- "images/icons-png/**"
- ];
+ "images/*.*",
+ "images/icons-png/**"
+];
- files.distZipContent = [
- files.cdn,
+files.distZipContent = [
+ files.cdn,
- files.css.theme.unminified,
- files.css.theme.minified,
+ files.css.theme.unminified,
+ files.css.theme.minified,
- "images/icons-svg/**",
- "demos/**"
- ];
+ "images/icons-svg/**",
+ "demos/**"
+];
- files.googleCDNZipOut = path.join( path.join( "<%= dist %>", "cdn-google" ),
- files.zipFileName );
+files.googleCDNZipOut = path.join( path.join( "<%= dist %>", "cdn-google" ),
+ files.zipFileName );
- return files;
+return files;
}
View
@@ -14,23 +14,23 @@ var fs = require( "fs" ),
copyrightMinFile = copyrightBaseName + ".min.txt";
module.exports = function( contents, ext, callback ) {
- var version = pkg.version.trim();
+var version = pkg.version.trim();
- if ( /^\.min/.test( ext ) ) {
- copyrightFile = copyrightMinFile;
- } else {
- copyrightFile = copyrightRegFile;
- }
- fs.readFile( path.join( buildDir, copyrightFile ), "utf8",
- function( err, copyright ) {
- if ( err ) {
- callback( err );
- } else {
- contents = copyright.replace( copyrightVersionRegExp, version ) + "\n" + contents;
- contents = contents.replace( apiVersionRegExp, "\"" + version + "\"" );
+if ( /^\.min/.test( ext ) ) {
+ copyrightFile = copyrightMinFile;
+} else {
+ copyrightFile = copyrightRegFile;
+}
+fs.readFile( path.join( buildDir, copyrightFile ), "utf8",
+ function( err, copyright ) {
+ if ( err ) {
+ callback( err );
+ } else {
+ contents = copyright.replace( copyrightVersionRegExp, version ) + "\n" + contents;
+ contents = contents.replace( apiVersionRegExp, "\"" + version + "\"" );
- callback( null, contents );
- }
+ callback( null, contents );
}
- );
+ }
+);
};
Oops, something went wrong.

0 comments on commit 6b9b2ab

Please sign in to comment.