added support for authentication

This commit is contained in:
matogertel 2013-08-30 11:14:05 +10:00
parent 0b295a3e15
commit a8e15100ac
1 changed files with 4 additions and 2 deletions

View File

@ -32,8 +32,9 @@ module.exports = function(grunt) {
done = this.async(); done = this.async();
parts = urls.parse(this.data.db); parts = urls.parse(this.data.db);
dbname = parts.pathname.replace(/^\//, ''); dbname = parts.pathname.replace(/^\//, '');
auth = parts.auth ? parts.auth+'@' : '';
try { try {
nano = require('nano')(parts.protocol + '//' + parts.host); nano = require('nano')(parts.protocol + '//' + auth + parts.host);
nano.db.destroy(dbname, function(err) { nano.db.destroy(dbname, function(err) {
if (err) { if (err) {
if (err.status_code && err.status_code === 404) { if (err.status_code && err.status_code === 404) {
@ -61,8 +62,9 @@ module.exports = function(grunt) {
done = this.async(); done = this.async();
parts = urls.parse(this.data.db); parts = urls.parse(this.data.db);
dbname = parts.pathname.replace(/^\//, ''); dbname = parts.pathname.replace(/^\//, '');
auth = parts.auth ? parts.auth+'@' : '';
try { try {
nano = require('nano')(parts.protocol + '//' + parts.host); nano = require('nano')(parts.protocol + '//' + auth + parts.host);
nano.db.create(dbname, function(err) { nano.db.create(dbname, function(err) {
if (_this.data.options && _this.data.options.okay_if_exists) { if (_this.data.options && _this.data.options.okay_if_exists) {
if (err){ if (err){