merged various branches; demo passes
This commit is contained in:
parent
d636e472b0
commit
eb0e451e38
82
package.json
82
package.json
|
@ -1,43 +1,43 @@
|
|||
{
|
||||
"name": "grunt-couchapp",
|
||||
"description": "A grunt plugin for building and uploading couchapps",
|
||||
"version": "0.1.0",
|
||||
"homepage": "https://github.com/elf/grunt-couchapp",
|
||||
"author": {
|
||||
"name": "Ken Elf Mathieu Sternberg",
|
||||
"email": "elf.sternberg@gmail.com",
|
||||
"url": "http://elfsternberg.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/elf/grunt-couchapp.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/elf/grunt-couchapp/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/elf/grunt-couchapp/blob/master/LICENSE-MIT"
|
||||
}
|
||||
],
|
||||
"main": "grunt.js",
|
||||
"bin": "bin/grunt-couchapp",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt test"
|
||||
},
|
||||
"dependencies": {
|
||||
"couchapp": "0.10.*",
|
||||
"grunt": "~0.3.12",
|
||||
"nano": "3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.3.12"
|
||||
},
|
||||
"keywords": [
|
||||
"gruntplugin"
|
||||
]
|
||||
"name": "grunt-couchapp",
|
||||
"description": "A grunt plugin for building and uploading couchapps",
|
||||
"version": "0.1.0",
|
||||
"homepage": "https://github.com/elf/grunt-couchapp",
|
||||
"author": {
|
||||
"name": "Ken Elf Mathieu Sternberg",
|
||||
"email": "elf.sternberg@gmail.com",
|
||||
"url": "http://elfsternberg.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/elf/grunt-couchapp.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/elf/grunt-couchapp/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/elf/grunt-couchapp/blob/master/LICENSE-MIT"
|
||||
}
|
||||
],
|
||||
"main": "grunt.js",
|
||||
"bin": "bin/grunt-couchapp",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt test"
|
||||
},
|
||||
"dependencies": {
|
||||
"couchapp": "0.10.*",
|
||||
"grunt": "~0.3.12",
|
||||
"nano": "3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.3.12"
|
||||
},
|
||||
"keywords": [
|
||||
"gruntplugin"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -5,12 +5,11 @@
|
|||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
var path, couchapp, nanolib, urls, async;
|
||||
var path, couchapp, nanolib, urls;
|
||||
|
||||
path = require('path');
|
||||
couchapp = require('couchapp');
|
||||
urls = require('url');
|
||||
async = require('async');
|
||||
|
||||
var genDB = function(db) {
|
||||
var parts, dbname, auth;
|
||||
|
@ -41,23 +40,14 @@ module.exports = function(grunt) {
|
|||
// ==========================================================================
|
||||
|
||||
grunt.registerMultiTask("couchapp", "Install Couchapp", function() {
|
||||
var task = this;
|
||||
var done = this.async();
|
||||
|
||||
async.each(this.files, function(file, cb) {
|
||||
var appobj, apppath
|
||||
apppath = path.join(process.cwd(), path.normalize(file.src[0]))
|
||||
try {
|
||||
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);
|
||||
var appobj, done;
|
||||
done = this.async();
|
||||
|
||||
appobj = require(path.join(process.cwd(), path.normalize(this.data.app)));
|
||||
|
||||
return couchapp.createApp(appobj, this.data.db, function(app) {
|
||||
return app.push(done);
|
||||
});
|
||||
});
|
||||
|
||||
grunt.registerMultiTask("rmcouchdb", "Delete a Couch Database", function() {
|
||||
|
@ -103,17 +93,18 @@ module.exports = function(grunt) {
|
|||
try {
|
||||
if (db.name) {
|
||||
nano = require('nano')(db.url);
|
||||
nano.db.create(db.name, function(err) {
|
||||
if (_this.data.options && _this.data.options.okay_if_exists) {
|
||||
if (err){
|
||||
nano.db.create(db.name, function(err, res) {
|
||||
if (err) {
|
||||
if (_this.data.options && _this.data.options.okay_if_exists) {
|
||||
grunt.log.writeln("Database " + db.name + " exists, skipping");
|
||||
return done(null, null);
|
||||
} else {
|
||||
grunt.warn("Database " + db.name + " exists, aborting.");
|
||||
return done(err, null);
|
||||
}
|
||||
return done(null, null);
|
||||
} else {
|
||||
if (err){
|
||||
grunt.warn(err);
|
||||
}
|
||||
return done(err, null);
|
||||
grunt.log.writeln("Database " + db.name + " created.");
|
||||
return done(null, null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue