Add okay_if_exists option to mkcouchdb
This commit is contained in:
parent
b514a1e27e
commit
840b93e7d2
|
@ -56,18 +56,25 @@ module.exports = function(grunt) {
|
|||
});
|
||||
|
||||
grunt.registerMultiTask("mkcouchdb", "Delete a Couch Database", function() {
|
||||
var done, parts, nano, dbname;
|
||||
|
||||
var done, parts, nano, dbname, _this;
|
||||
_this = this;
|
||||
done = this.async();
|
||||
parts = urls.parse(this.data.db);
|
||||
dbname = parts.pathname.replace(/^\//, '');
|
||||
try {
|
||||
nano = require('nano')(parts.protocol + '//' + parts.host);
|
||||
nano.db.create(dbname, function(err) {
|
||||
if (err) {
|
||||
grunt.warn(err);
|
||||
if (_this.data.options && _this.data.options.okay_if_exists) {
|
||||
if (err){
|
||||
grunt.log.writeln("Database " + dbname + " exists, skipping");
|
||||
}
|
||||
return done(null, null);
|
||||
} else {
|
||||
if (err){
|
||||
grunt.warn(err);
|
||||
}
|
||||
return done(err, null);
|
||||
}
|
||||
return done(err, null);
|
||||
});
|
||||
} catch (e) {
|
||||
grunt.warn(e);
|
||||
|
|
Loading…
Reference in New Issue