Created
August 15, 2014 22:06
-
-
Save goldsmith/85de1956e34ed93aec32 to your computer and use it in GitHub Desktop.
PurgeCDN Grunt task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.registerTask('purgecdn', 'Purge MaxCDN pull zone', function() { | |
var done = this.async(); | |
grunt.config.requires('maxcdn'); | |
var maxcdn = grunt.config('maxcdn'); | |
var api = new MaxCDN( | |
maxcdn.companyAlias, maxcdn.consumerKey, maxcdn.consumerSecret | |
); | |
grunt.log.writeln('purging cache for Pull Zone #' + maxcdn.pullZoneId + '...'); | |
api.del('zones/pull.json/' + maxcdn.pullZoneId + '/cache', function callback(err, response) { | |
if (err) { | |
grunt.log.error(JSON.parse(err.data).error.message); | |
done(false); | |
return; | |
} | |
grunt.log.writeln('successfully purged!'); | |
done(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment