cleanup and error catching

This commit is contained in:
skiqh 2013-07-03 19:27:18 +02:00
parent 81f490a1f5
commit af73a33070
1 changed files with 17 additions and 12 deletions

View File

@ -5,13 +5,12 @@
* Licensed under the MIT license. * Licensed under the MIT license.
*/ */
var path, couchapp, nanolib, urls; var path, couchapp, nanolib, urls, async;
path = require('path'); path = require('path');
couchapp = require('couchapp'); couchapp = require('couchapp');
urls = require('url'); urls = require('url');
console.log(__dirname) async = require('async');
var async = require('async')
module.exports = function(grunt) { module.exports = function(grunt) {
@ -20,17 +19,23 @@ module.exports = function(grunt) {
// ========================================================================== // ==========================================================================
grunt.registerMultiTask("couchapp", "Install Couchapp", function() { grunt.registerMultiTask("couchapp", "Install Couchapp", function() {
var task = this;
var task = this var done = this.async();
var done = this.async()
async.each(this.files, function(file, cb) { async.each(this.files, function(file, cb) {
var pth = path.join(process.cwd(), path.normalize(file.src[0])) var appobj, apppath
var appobj = require(pth) apppath = path.join(process.cwd(), path.normalize(file.src[0]))
couchapp.createApp(appobj, task.data.db, function(app) { try {
app.push( cb ) appobj = require(apppath)
}); couchapp.createApp(appobj, task.data.db, function(app) {
}, done) app.push(cb);
});
} catch(ex) {
grunt.log.error(ex);
grunt.log.warn('Could not load couchapp from ' + apppath + '.');
cb();
}
}, done);
}); });
grunt.registerMultiTask("rmcouchdb", "Delete a Couch Database", function() { grunt.registerMultiTask("rmcouchdb", "Delete a Couch Database", function() {