rmcouchdb doesn't drop everything if dbname is absent; mkcouchdb reports helpful error message if dbname is absent
This commit is contained in:
parent
af73a33070
commit
a41ae8efac
|
@ -68,8 +68,7 @@ possible to write in your configuration file:
|
|||
});
|
||||
|
||||
|
||||
Note, however, that if you call 'rmcouchdb' without a sub-argument, in
|
||||
keeping with grunt's standards, it will drop *all* of your databases!
|
||||
Note that if you call `rmcouchdb` without a sub-argument, it will not delete any databases.
|
||||
|
||||
## Demo
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ module.exports = function(grunt) {
|
|||
dbname = parts.pathname.replace(/^\//, '');
|
||||
try {
|
||||
nano = require('nano')(parts.protocol + '//' + parts.host);
|
||||
if (dbname) {
|
||||
nano.db.destroy(dbname, function(err) {
|
||||
if (err) {
|
||||
if (err.status_code && err.status_code === 404) {
|
||||
|
@ -61,6 +62,10 @@ module.exports = function(grunt) {
|
|||
}
|
||||
return done(err, null);
|
||||
});
|
||||
} else {
|
||||
grunt.log.writeln("No database specified... skipping.");
|
||||
return done(null, null);
|
||||
}
|
||||
} catch (e) {
|
||||
grunt.warn(e);
|
||||
done(e, null);
|
||||
|
@ -74,6 +79,7 @@ module.exports = function(grunt) {
|
|||
parts = urls.parse(this.data.db);
|
||||
dbname = parts.pathname.replace(/^\//, '');
|
||||
try {
|
||||
if (dbname) {
|
||||
nano = require('nano')(parts.protocol + '//' + parts.host);
|
||||
nano.db.create(dbname, function(err) {
|
||||
if (_this.data.options && _this.data.options.okay_if_exists) {
|
||||
|
@ -88,6 +94,11 @@ module.exports = function(grunt) {
|
|||
return done(err, null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var err_msg = "No database specified... skipping.";
|
||||
grunt.warn(err_msg);
|
||||
return done(new Error(err_msg), null);
|
||||
}
|
||||
} catch (e) {
|
||||
grunt.warn(e);
|
||||
done(e, null);
|
||||
|
|
Loading…
Reference in New Issue