Skip to content

Commit

Permalink
async task
Browse files Browse the repository at this point in the history
  • Loading branch information
siacomuzzi committed Feb 20, 2014
1 parent 233ed44 commit 0aba5d5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tasks/maxcdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ module.exports = function (grunt) {

grunt.registerMultiTask('maxcdn', 'Interact with the MaxCDN API', function () {

var done = this.async();
var options = this.options();

if (!this.files) {
grunt.fail.fatal('files is mandatory');
return done();
}

if (!options.zone_id) {
grunt.fail.fatal('options.zone_id is mandatory');
return done();
}

if (options.method !== 'delete') {
grunt.fail.fatal('Sorry! Only delete method is supported.');
return done();
}

var files = [];
Expand All @@ -35,14 +39,15 @@ module.exports = function (grunt) {

maxcdn.delete(
'zones/pull.json/' + options.zone_id + '/cache',
{ files: this.files },
{ files: files },
function (err, response) {
if (err) {
grunt.log.error(err);
return;
return done();
}

console.log(response);
done(true);
});
});

Expand Down

0 comments on commit 0aba5d5

Please sign in to comment.