From 508e1eec96b5ee02c5cc10013842a219197b7699 Mon Sep 17 00:00:00 2001 From: Sam Hiatt Date: Fri, 12 Sep 2014 18:50:10 -0700 Subject: [PATCH] Fixes bug where 'database exists' is reported when other couchdb errors are encountered. --- tasks/couchapp.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tasks/couchapp.js b/tasks/couchapp.js index ebbc3d9..0d24d33 100755 --- a/tasks/couchapp.js +++ b/tasks/couchapp.js @@ -96,12 +96,17 @@ module.exports = function(grunt) { } else if (err.code && err.description) { // probably connection error throw err; } - else if (_this.data.options && _this.data.options.okay_if_exists) { - grunt.log.writeln("Database " + db.name + " exists, skipping"); - return done(null, null); + else if (err.error && err.error=="file_exists") { + if (_this.data.options && _this.data.options.okay_if_exists) { + grunt.log.writeln("Database " + db.name + " exists, skipping"); + return done(null, null); + } else { + grunt.warn("Database " + db.name + " exists and okay_if_exists set to false. Aborting."); + throw err; + } } else { - grunt.warn("Database " + db.name + " exists and okay_if_exists set to false. Aborting."); - throw err; + console.warn("Unrecognized error."); + throw err } } else if (res && res.ok==true) { grunt.log.ok("Database " + db.name + " created.");