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() {
|
grunt.registerMultiTask("mkcouchdb", "Delete a Couch Database", function() {
|
||||||
var done, parts, nano, dbname;
|
var done, parts, nano, dbname, _this;
|
||||||
|
_this = this;
|
||||||
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(/^\//, '');
|
||||||
try {
|
try {
|
||||||
nano = require('nano')(parts.protocol + '//' + parts.host);
|
nano = require('nano')(parts.protocol + '//' + 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 (err){
|
||||||
|
grunt.log.writeln("Database " + dbname + " exists, skipping");
|
||||||
|
}
|
||||||
|
return done(null, null);
|
||||||
|
} else {
|
||||||
if (err){
|
if (err){
|
||||||
grunt.warn(err);
|
grunt.warn(err);
|
||||||
}
|
}
|
||||||
return done(err, null);
|
return done(err, null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
grunt.warn(e);
|
grunt.warn(e);
|
||||||
|
|
Loading…
Reference in New Issue