Skip to content

Instantly share code, notes, and snippets.

@shimaore
Created February 23, 2011 14:46
Show Gist options
  • Save shimaore/840501 to your computer and use it in GitHub Desktop.
Save shimaore/840501 to your computer and use it in GitHub Desktop.
A simple patch to add one argument (the Base64-encoded value of the "Basic" authorization HTTP header) to node.couchapp.js.
diff --git a/bin.js b/bin.js
index 21a4f35..4a7c8ae 100755
--- a/bin.js
+++ b/bin.js
@@ -14,6 +14,7 @@ var node = process.argv.shift()
, command = process.argv.shift()
, app = process.argv.shift()
, couch = process.argv.shift()
+ , auth = process.argv.shift()
;
if (command == 'help' || command == undefined) {
@@ -21,7 +22,7 @@ if (command == 'help' || command == undefined) {
[ "couchapp -- utility for creating couchapps"
, ""
, "Usage:"
- , " couchapp <command> app.js http://localhost:5984/dbname"
+ , " couchapp <command> app.js http://localhost:5984/dbname [auth]"
, ""
, "Commands:"
, " push : Push app once to server."
@@ -65,7 +66,7 @@ if (command == 'boiler') {
copytree(path.join(__dirname, 'boiler'), path.join(process.env.PWD, app));
} else {
- couchapp.createApp(require(abspath(app)), couch, function (app) {
+ couchapp.createApp(require(abspath(app)), couch, auth, function (app) {
if (command == 'push') app.push()
else if (command == 'sync') app.sync()
diff --git a/main.js b/main.js
index f20574d..6cbf9ab 100644
--- a/main.js
+++ b/main.js
@@ -33,8 +33,12 @@ function playSound () {
spawn("/usr/bin/afplay", ["/System/Library/Sounds/Blow.aiff"]);
}
-function createApp (doc, url, cb) {
+function createApp (doc, url, auth, cb) {
var app = {doc:doc}
+
+ if(auth) {
+ h.Authorization = "Basic "+auth;
+ }
app.fds = {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment