merged various branches; demo passes
This commit is contained in:
parent
d636e472b0
commit
eb0e451e38
|
@ -5,12 +5,11 @@
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var path, couchapp, nanolib, urls, async;
|
var path, couchapp, nanolib, urls;
|
||||||
|
|
||||||
path = require('path');
|
path = require('path');
|
||||||
couchapp = require('couchapp');
|
couchapp = require('couchapp');
|
||||||
urls = require('url');
|
urls = require('url');
|
||||||
async = require('async');
|
|
||||||
|
|
||||||
var genDB = function(db) {
|
var genDB = function(db) {
|
||||||
var parts, dbname, auth;
|
var parts, dbname, auth;
|
||||||
|
@ -41,23 +40,14 @@ module.exports = function(grunt) {
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
grunt.registerMultiTask("couchapp", "Install Couchapp", function() {
|
grunt.registerMultiTask("couchapp", "Install Couchapp", function() {
|
||||||
var task = this;
|
var appobj, done;
|
||||||
var done = this.async();
|
done = this.async();
|
||||||
|
|
||||||
async.each(this.files, function(file, cb) {
|
appobj = require(path.join(process.cwd(), path.normalize(this.data.app)));
|
||||||
var appobj, apppath
|
|
||||||
apppath = path.join(process.cwd(), path.normalize(file.src[0]))
|
return couchapp.createApp(appobj, this.data.db, function(app) {
|
||||||
try {
|
return app.push(done);
|
||||||
appobj = require(apppath)
|
|
||||||
couchapp.createApp(appobj, task.data.db, function(app) {
|
|
||||||
app.push(cb);
|
|
||||||
});
|
});
|
||||||
} catch(ex) {
|
|
||||||
grunt.log.error(ex);
|
|
||||||
grunt.log.warn('Could not load couchapp from ' + apppath + '.');
|
|
||||||
cb();
|
|
||||||
}
|
|
||||||
}, done);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerMultiTask("rmcouchdb", "Delete a Couch Database", function() {
|
grunt.registerMultiTask("rmcouchdb", "Delete a Couch Database", function() {
|
||||||
|
@ -103,18 +93,19 @@ module.exports = function(grunt) {
|
||||||
try {
|
try {
|
||||||
if (db.name) {
|
if (db.name) {
|
||||||
nano = require('nano')(db.url);
|
nano = require('nano')(db.url);
|
||||||
nano.db.create(db.name, function(err) {
|
nano.db.create(db.name, function(err, res) {
|
||||||
if (_this.data.options && _this.data.options.okay_if_exists) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
if (_this.data.options && _this.data.options.okay_if_exists) {
|
||||||
grunt.log.writeln("Database " + db.name + " exists, skipping");
|
grunt.log.writeln("Database " + db.name + " exists, skipping");
|
||||||
}
|
|
||||||
return done(null, null);
|
return done(null, null);
|
||||||
} else {
|
} else {
|
||||||
if (err){
|
grunt.warn("Database " + db.name + " exists, aborting.");
|
||||||
grunt.warn(err);
|
|
||||||
}
|
|
||||||
return done(err, null);
|
return done(err, null);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
grunt.log.writeln("Database " + db.name + " created.");
|
||||||
|
return done(null, null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var err_msg = "No database specified to create!";
|
var err_msg = "No database specified to create!";
|
||||||
|
|
Loading…
Reference in New Issue