From 81579ec2e3db6327969f0f7cfcaab2b6afedec11 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Sat, 18 Jul 2015 16:36:13 -0400 Subject: [PATCH] Redirects: Add support for setting redirects in redirects.json Ref jquery/grunt-jquery-content#61 Closes gh-69 --- package.json | 3 ++- tasks/redirects.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tasks/redirects.js diff --git a/package.json b/package.json index 7023694..267b853 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "marked": "0.3.2", "rimraf": "2.2.8", "spawnback": "1.0.0", - "which": "1.0.5" + "which": "1.0.5", + "wordpress": "0.1.3" }, "devDependencies": { "grunt": "0.4.5", diff --git a/tasks/redirects.js b/tasks/redirects.js new file mode 100644 index 0000000..c51bd0f --- /dev/null +++ b/tasks/redirects.js @@ -0,0 +1,15 @@ +module.exports = function( grunt ) { + +var wp = require( "wordpress" ); + +grunt.registerTask( "deploy-redirects", function() { + var config = grunt.config( "wordpress" ); + var redirects = grunt.file.exists( "redirects.json" ) ? grunt.file.readJSON( "redirects.json" ) : {}; + var client = wp.createClient( config ); + + client.authenticatedCall( "jq.setRedirects", JSON.stringify( redirects ), this.async() ); +} ); + +grunt.registerTask( "deploy", [ "wordpress-deploy", "deploy-redirects" ] ); + +};