Skip to content

Commit 25eae07

Browse files
committed
Build: Reload all listing pages after deploying to WordPress
Fixes jquerygh-7
1 parent 73fdd0d commit 25eae07

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

grunt.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ module.exports = function( grunt ) {
44

55
var _ = require( "underscore" ),
66
semver = require( "semver" ),
7-
Handlebars = require( "handlebars" );
7+
Handlebars = require( "handlebars" ),
8+
http = require( "http" );
89

910
grunt.loadNpmTasks( "grunt-clean" );
1011
grunt.loadNpmTasks( "grunt-html" );
@@ -45,10 +46,6 @@ grunt.initConfig({
4546
}, grunt.file.readJSON( "config.json" ) )
4647
});
4748

48-
grunt.registerTask( "default", "build-wordpress" );
49-
grunt.registerTask( "build", "build-pages build-resources build-index" );
50-
grunt.registerTask( "build-wordpress", "check-modules clean lint build" );
51-
5249
grunt.registerTask( "build-index", function() {
5350
var rversion = /^(\d+)\.(\d+)(?:\.(\d+))?-?(.*)$/;
5451
function normalizeVersion( version ) {
@@ -344,4 +341,36 @@ grunt.registerTask( "build-index", function() {
344341
Handlebars.compile( grunt.file.read( "templates/qunit.hbs" ) )( data ) );
345342
});
346343

344+
grunt.registerTask( "reload-listings", function() {
345+
var done = this.async(),
346+
host = "http://" + grunt.config( "wordpress" ).url,
347+
paths = [ "/", "/jquery/", "/ui/", "/mobile/", "/color/", "/qunit/" ],
348+
waiting = paths.length;
349+
350+
paths.forEach(function( path ) {
351+
path = host + path;
352+
http.get( path + "?reload", function( response ) {
353+
if ( response.statusCode >= 400 ) {
354+
grunt.log.error( "Error reloading " + path );
355+
grunt.log.error( "Status code: " + response.statusCode );
356+
return done( false );
357+
}
358+
359+
grunt.log.writeln( "Successfully reloaded " + path );
360+
if ( !--waiting ) {
361+
done();
362+
}
363+
}).on( "error", function( error ) {
364+
grunt.log.error( "Error loading " + path );
365+
grunt.log.error( error );
366+
done( false );
367+
});
368+
});
369+
});
370+
371+
grunt.registerTask( "default", "build-wordpress" );
372+
grunt.registerTask( "build", "build-pages build-resources build-index" );
373+
grunt.registerTask( "build-wordpress", "check-modules clean lint build" );
374+
grunt.registerTask( "deploy", "wordpress-deploy reload-listings" );
375+
347376
};

0 commit comments

Comments
 (0)