From a8e15100accb0fcd3b741856c1125f703acb6d7c Mon Sep 17 00:00:00 2001 From: matogertel Date: Fri, 30 Aug 2013 11:14:05 +1000 Subject: [PATCH] added support for authentication --- tasks/couchapp.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/couchapp.js b/tasks/couchapp.js index 6b7811f..08b0157 100644 --- a/tasks/couchapp.js +++ b/tasks/couchapp.js @@ -32,8 +32,9 @@ module.exports = function(grunt) { done = this.async(); parts = urls.parse(this.data.db); dbname = parts.pathname.replace(/^\//, ''); + auth = parts.auth ? parts.auth+'@' : ''; try { - nano = require('nano')(parts.protocol + '//' + parts.host); + nano = require('nano')(parts.protocol + '//' + auth + parts.host); nano.db.destroy(dbname, function(err) { if (err) { if (err.status_code && err.status_code === 404) { @@ -61,8 +62,9 @@ module.exports = function(grunt) { done = this.async(); parts = urls.parse(this.data.db); dbname = parts.pathname.replace(/^\//, ''); + auth = parts.auth ? parts.auth+'@' : ''; try { - nano = require('nano')(parts.protocol + '//' + parts.host); + nano = require('nano')(parts.protocol + '//' + auth + parts.host); nano.db.create(dbname, function(err) { if (_this.data.options && _this.data.options.okay_if_exists) { if (err){