From c465b842b0b4a8473e8925d98619b97e3d3a7362 Mon Sep 17 00:00:00 2001
From: ashg1910
Date: Mon, 30 Mar 2015 00:56:23 +0530
Subject: [PATCH 1/2] Properly indented gruntfile
---
Gruntfile.js | 406 ++++++++++++++++++++++++++-------------------------
1 file changed, 204 insertions(+), 202 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index a10a39a..3a64c28 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -4,122 +4,122 @@ var exec = require( "child_process" ).exec,
module.exports = function( grunt ) {
-grunt.loadNpmTasks( "grunt-jquery-content" );
-
-grunt.initConfig({
- "build-posts": {
- page: "page/**"
- },
- "build-resources": {
- all: "resources/**"
- },
- wordpress: (function() {
- var config = require( "./config" );
- config.dir = "dist/wordpress";
- return config;
- })()
-});
-
-grunt.registerTask( "build-download", function() {
- function writeFiles() {
- var frontend = require( "download.jqueryui.com" ).frontend({
- host: "http://download.jqueryui.com",
- env: "production"
- }),
- download = frontend.download,
- themeroller = frontend.themeroller,
- wordpressDir = grunt.config( "wordpress.dir" ),
- resourceCount = 0;
-
- grunt.file.write( wordpressDir + "/posts/page/download.html",
- "\n" + download.index() );
-
- grunt.file.write( wordpressDir + "/posts/page/themeroller.html",
- "\n" + themeroller.index() );
-
- grunt.file.expand( { filter: "isFile" }, dir + "/app/dist/**" ).forEach(function( file ) {
- grunt.file.copy( file,
- file.replace( dir + "/app/dist", wordpressDir + "/resources" ) );
- resourceCount++;
- });
-
- grunt.log.writeln( "Wrote download.html, themeroller.html and " +
- resourceCount + " resources." );
- }
-
- var path = require( "path" ),
- dir = path.dirname( require.resolve( "download.jqueryui.com" ) ),
- done = this.async();
-
- if ( grunt.option( "noprepare" ) ) {
- writeFiles();
- return done();
- }
-
- // At this point, the download builder repo is available, so let's initialize it
- grunt.log.writeln( "Initializing download module, might take a while..." );
- exec( "grunt prepare", {
+ grunt.loadNpmTasks( "grunt-jquery-content" );
+
+ grunt.initConfig({
+ "build-posts": {
+ page: "page/**"
+ },
+ "build-resources": {
+ all: "resources/**"
+ },
+ wordpress: (function() {
+ var config = require( "./config" );
+ config.dir = "dist/wordpress";
+ return config;
+ })()
+ });
+
+ grunt.registerTask( "build-download", function() {
+ function writeFiles() {
+ var frontend = require( "download.jqueryui.com" ).frontend({
+ host: "http://download.jqueryui.com",
+ env: "production"
+ }),
+ download = frontend.download,
+ themeroller = frontend.themeroller,
+ wordpressDir = grunt.config( "wordpress.dir" ),
+ resourceCount = 0;
+
+ grunt.file.write( wordpressDir + "/posts/page/download.html",
+ "\n" + download.index() );
+
+ grunt.file.write( wordpressDir + "/posts/page/themeroller.html",
+ "\n" + themeroller.index() );
+
+ grunt.file.expand( { filter: "isFile" }, dir + "/app/dist/**" ).forEach(function( file ) {
+ grunt.file.copy( file,
+ file.replace( dir + "/app/dist", wordpressDir + "/resources" ) );
+ resourceCount++;
+ });
+
+ grunt.log.writeln( "Wrote download.html, themeroller.html and " +
+ resourceCount + " resources." );
+ }
+
+ var path = require( "path" ),
+ dir = path.dirname( require.resolve( "download.jqueryui.com" ) ),
+ done = this.async();
+
+ if ( grunt.option( "noprepare" ) ) {
+ writeFiles();
+ return done();
+ }
+
+ // At this point, the download builder repo is available, so let's initialize it
+ grunt.log.writeln( "Initializing download module, might take a while..." );
+ exec( "grunt prepare", {
cwd: "node_modules/download.jqueryui.com"
- }, function( error, stdout, stderr ) {
- if ( error ) {
- grunt.log.error( stderr );
- return done( error );
- }
-
- writeFiles();
- done();
- });
-});
-
-grunt.registerTask( "build-demos", function() {
- function sortByTitle( a, b ) {
- if ( a.filename === "default" ) {
- return -1;
- }
- if ( b.filename === "default" ) {
- return 1;
- }
- return a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1;
- }
-
- // We hijack the jquery-ui checkout from download.jqueryui.com
- this.requires( "build-download" );
-
- var jqueryCore, subdir,
- path = require( "path" ),
- cheerio = require( "cheerio" ),
- downloadBuilder = require( "download.jqueryui.com" ),
- stable = downloadBuilder.JqueryUi.getStable(),
- repoDir = path.normalize( stable.path ),
- demosDir = repoDir + "demos",
- externalDir = (repoDir + "external").replace( process.cwd() + "/", "" ),
- targetDir = grunt.config( "wordpress.dir" ) + "/resources/demos",
- highlightDir = targetDir + "-highlight",
- demoList = {};
-
- jqueryCore = stable.files().jqueryCore[ 0 ].data.match( /jQuery JavaScript Library v([0-9.]*)/ )[ 1 ];
-
- // Copy all demos files to /resources/demos
- grunt.file.recurse( demosDir, function( abspath, rootdir, subdir, filename ) {
- if ( filename === "index.html" ) {
- return;
- }
-
- var content, $,
- dest = targetDir + "/" + subdir + "/" + filename,
- highlightDest = highlightDir + "/" + subdir + "/" + filename;
-
- if ( /html$/.test( filename ) ) {
- content = replaceResources( grunt.file.read( abspath ) );
-
- if ( !( /(\/)/.test( subdir ) ) ) {
- $ = cheerio.load( content );
+ }, function( error, stdout, stderr ) {
+ if ( error ) {
+ grunt.log.error( stderr );
+ return done( error );
+ }
+
+ writeFiles();
+ done();
+ });
+ });
+
+ grunt.registerTask( "build-demos", function() {
+ function sortByTitle( a, b ) {
+ if ( a.filename === "default" ) {
+ return -1;
+ }
+ if ( b.filename === "default" ) {
+ return 1;
+ }
+ return a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1;
+ }
+
+ // We hijack the jquery-ui checkout from download.jqueryui.com
+ this.requires( "build-download" );
+
+ var jqueryCore, subdir,
+ path = require( "path" ),
+ cheerio = require( "cheerio" ),
+ downloadBuilder = require( "download.jqueryui.com" ),
+ stable = downloadBuilder.JqueryUi.getStable(),
+ repoDir = path.normalize( stable.path ),
+ demosDir = repoDir + "demos",
+ externalDir = (repoDir + "external").replace( process.cwd() + "/", "" ),
+ targetDir = grunt.config( "wordpress.dir" ) + "/resources/demos",
+ highlightDir = targetDir + "-highlight",
+ demoList = {};
+
+ jqueryCore = stable.files().jqueryCore[ 0 ].data.match( /jQuery JavaScript Library v([0-9.]*)/ )[ 1 ];
+
+ // Copy all demos files to /resources/demos
+ grunt.file.recurse( demosDir, function( abspath, rootdir, subdir, filename ) {
+ if ( filename === "index.html" ) {
+ return;
+ }
+
+ var content, $,
+ dest = targetDir + "/" + subdir + "/" + filename,
+ highlightDest = highlightDir + "/" + subdir + "/" + filename;
+
+ if ( /html$/.test( filename ) ) {
+ content = replaceResources( grunt.file.read( abspath ) );
+
+ if ( !( /(\/)/.test( subdir ) ) ) {
+ $ = cheerio.load( content );
if ( !demoList[ subdir ] ) {
demoList[ subdir ] = [];
}
@@ -137,93 +137,95 @@ grunt.registerTask( "build-demos", function() {
$ = cheerio.load( "
" );
$( "code" ).text( content );
grunt.file.write( highlightDest, jqueryContent.syntaxHighlight( $.html() ) );
- } else {
+ }
+ else {
grunt.file.write( dest, content );
- }
- } else {
- grunt.file.copy( abspath, dest );
- }
- });
-
- for ( subdir in demoList ) {
- demoList[ subdir ].sort( sortByTitle );
- }
-
- // Create list of all demos
- grunt.file.write( targetDir + "/demo-list.json", JSON.stringify( demoList, null, "\t" ) );
-
- // Copy externals into /resources/demos/external
- grunt.file.expand( { filter: "isFile" }, externalDir + "/**" ).forEach(function( filename ) {
- grunt.file.copy( filename, targetDir + "/external/" + filename.replace( externalDir, "" ) );
- });
-
- function replaceResources( source ) {
- // ../../jquery-x.y.z.js -> CDN
- source = source.replace(
- //,
- "" );
-
- // ../../ui/* -> CDN
- // Only the first script is replaced, all subsequent scripts are dropped,
- // including the full line
- source = source.replace(
- /" );
- source = source.replace(
- /^.* /resources/demos/external/*
- source = source.replace(
- / CDN
- source = source.replace(
- /" );
-
- // ../demos.css -> /resources/demos/style.css
- source = source.replace(
- //,
- "" );
-
- return source;
- }
-});
-
-grunt.registerTask( "copy-taxonomies", function() {
- grunt.file.copy( "taxonomies.json",
- grunt.config( "wordpress.dir" ) + "/taxonomies.json" );
-});
-
-grunt.registerTask( "create-quickdownload", function() {
-
- // We hijack the jquery-ui checkout from download.jqueryui.com
- this.requires( "build-download" );
-
- var done = this.async(),
- path = require( "path" );
-
- exec( "grunt build-packages:" + path.resolve( "resources/download" ), {
- cwd: "node_modules/download.jqueryui.com"
- }, function( error, stdout, stderr ) {
- if ( error ) {
- grunt.log.error( stderr );
- return done( error );
- }
-
- grunt.log.write( stdout );
- done();
- });
-});
-
-grunt.registerTask( "build", [
- "build-posts",
- "build-resources",
- "build-download",
- "build-demos",
- "copy-taxonomies"
-]);
+ }
+ }
+ else {
+ grunt.file.copy( abspath, dest );
+ }
+ });
+
+ for ( subdir in demoList ) {
+ demoList[ subdir ].sort( sortByTitle );
+ }
+
+ // Create list of all demos
+ grunt.file.write( targetDir + "/demo-list.json", JSON.stringify( demoList, null, "\t" ) );
+
+ // Copy externals into /resources/demos/external
+ grunt.file.expand( { filter: "isFile" }, externalDir + "/**" ).forEach(function( filename ) {
+ grunt.file.copy( filename, targetDir + "/external/" + filename.replace( externalDir, "" ) );
+ });
+
+ function replaceResources( source ) {
+ // ../../jquery-x.y.z.js -> CDN
+ source = source.replace(
+ //,
+ "" );
+
+ // ../../ui/* -> CDN
+ // Only the first script is replaced, all subsequent scripts are dropped,
+ // including the full line
+ source = source.replace(
+ /" );
+ source = source.replace(
+ /^.* /resources/demos/external/*
+ source = source.replace(
+ / CDN
+ source = source.replace(
+ /" );
+
+ // ../demos.css -> /resources/demos/style.css
+ source = source.replace(
+ //,
+ "" );
+
+ return source;
+ }
+ });
+
+ grunt.registerTask( "copy-taxonomies", function() {
+ grunt.file.copy( "taxonomies.json",
+ grunt.config( "wordpress.dir" ) + "/taxonomies.json" );
+ });
+
+ grunt.registerTask( "create-quickdownload", function() {
+
+ // We hijack the jquery-ui checkout from download.jqueryui.com
+ this.requires( "build-download" );
+
+ var done = this.async(),
+ path = require( "path" );
+
+ exec( "grunt build-packages:" + path.resolve( "resources/download" ), {
+ cwd: "node_modules/download.jqueryui.com"
+ }, function( error, stdout, stderr ) {
+ if ( error ) {
+ grunt.log.error( stderr );
+ return done( error );
+ }
+
+ grunt.log.write( stdout );
+ done();
+ });
+ });
+
+ grunt.registerTask( "build", [
+ "build-posts",
+ "build-resources",
+ "build-download",
+ "build-demos",
+ "copy-taxonomies"
+ ]);
};
From 165ad78c94d6f0258ea1c6f8526397a03b82781e Mon Sep 17 00:00:00 2001
From: ashg1910
Date: Mon, 30 Mar 2015 01:02:14 +0530
Subject: [PATCH 2/2] Gruntfile.js properly indented
---
Gruntfile.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 3a64c28..18e80d3 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -8,7 +8,7 @@ module.exports = function( grunt ) {
grunt.initConfig({
"build-posts": {
- page: "page/**"
+ page: "page/**"
},
"build-resources": {
all: "resources/**"
@@ -25,11 +25,11 @@ module.exports = function( grunt ) {
var frontend = require( "download.jqueryui.com" ).frontend({
host: "http://download.jqueryui.com",
env: "production"
- }),
- download = frontend.download,
- themeroller = frontend.themeroller,
- wordpressDir = grunt.config( "wordpress.dir" ),
- resourceCount = 0;
+ }),
+ download = frontend.download,
+ themeroller = frontend.themeroller,
+ wordpressDir = grunt.config( "wordpress.dir" ),
+ resourceCount = 0;
grunt.file.write( wordpressDir + "/posts/page/download.html",
"" + JSON.stringify({