You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a grunt task from this api to integrate it with my Gruntfile:
grunt.registerMultiTask('neocities','Upload files to the Neocities web-service',function(){'use strict';vardone=this.async();varNeoCities=require('neocities');varoptions=this.options();if(options.username===undefined||options.password===undefined){grunt.log.writeln(options);grunt.log.error('options.username and options.password are mandatory !');done(false);return;}varapi=newNeoCities(options.username,options.password);varuploads=[];this.files.forEach(function(filePair){if(filePair.src.length!=1&&filePair.dest!==undefined){grunt.log.error('Same destination for multiple sources ?!');done(false);return;}filePair.src.forEach(function(src){varpair={path: src};if(filePair.dest!==undefined){pair.name=filePair.dest;}else{pair.name=src.split(/[\\/]/).pop();}uploads.push(pair);});});api.upload(uploads,function(resp){if(resp.result=='error'){grunt.log.error(resp.message);done(false);return;}grunt.log.writeln(resp.message);done(true);})});
I created a grunt task from this api to integrate it with my Gruntfile:
I use the task as follow:
Some more flexibility is allowed (src ->dest mapping), see the code.
I thought maybe you're interested in publishing it.
It is the first time I wrote a grunt task, so there are probably lots of improvements to do.
Cheers !
The text was updated successfully, but these errors were encountered: