Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 8 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
4 .travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - "0.8"
+ - "0.10"
View
8 index.js
@@ -167,6 +167,14 @@ Ploy.prototype.listen = function () {
return this.bouncer.listen.apply(this.bouncer, arguments);
};
+Ploy.prototype.address = function () {
+ return this.bouncer.address.apply(this.bouncer, arguments);
+};
+
+Ploy.prototype.close = function () {
+ this.bouncer.close();
+};
+
Ploy.prototype.handle = function (req, res) {
if (RegExp('^/_ploy/[^?]+\\.git\\b').test(req.url)) {
req.url = req.url.replace(RegExp('^/_ploy/'), '/');
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "ploy",
- "version": "0.2.1",
+ "version": "0.2.2",
"description": "git push deploy http router, hosting branches on subdomains",
"bin": {
"ploy": "bin/cmd.js"
View
2  readme.markdown
@@ -2,6 +2,8 @@
git push at this http router and it will host your branches on subdomains
+[![build status](https://secure.travis-ci.org/substack/ploy.png)](http://travis-ci.org/substack/ploy)
+
think [bouncy](https://github.com/substack/bouncy) +
[cicada](https://github.com/substack/cicada)
View
5 test/commit.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+git checkout -b staging
+sed -i 's/beep boop/rawr/g' server.js
+git add server.js
+git commit -m'rawr!'
View
91 test/deploy.js
@@ -0,0 +1,91 @@
+var test = require('tap').test;
+var ploy = require('../');
+var path = require('path');
+var spawn = require('child_process').spawn;
+var hyperquest = require('hyperquest');
+var concat = require('concat-stream');
+
+function setup (t) {
+ var ps = spawn(__dirname + '/setup.sh', [], {
+ cwd: __dirname
+ });
+ ps.on('exit', t.end.bind(t));
+}
+
+function teardown (t) {
+ var ps = spawn(__dirname + '/teardown.sh', [], {
+ cwd: __dirname
+ });
+ ps.stderr.pipe(process.stderr);
+ ps.on('exit', t.end.bind(t));
+ t.on('end', function () {
+ setTimeout(process.exit, 500);
+ });
+}
+
+function commit (cb) {
+ var ps = spawn(__dirname + '/commit.sh', [], {
+ cwd: __dirname + '/repo'
+ });
+ ps.on('exit', cb);
+}
+
+function push (branch, cb) {
+ var args = [
+ 'push',
+ 'http://localhost:' + port + '/_ploy/repo.git',
+ branch
+ ];
+ var ps = spawn('git', args, {
+ cwd: __dirname + '/repo'
+ });
+ ps.on('exit', cb);
+}
+
+var tmpDir = '/tmp/ploy-test/' + Math.random();
+var server = ploy(tmpDir);
+var port;
+
+test(setup);
+test(function (t) {
+ t.plan(5);
+ server.listen(function () {
+ port = server.address().port;
+ setTimeout(push0, 2000);
+ });
+
+ function push0 () {
+ push('master', function (code) {
+ t.equal(code, 0);
+ setTimeout(function () {
+ verify('beep boop\n', 'local', deploy);
+ }, 3000);
+ });
+ }
+
+ function push1 () {
+ push('staging', function (code) {
+ t.equal(code, 0);
+ setTimeout(function () {
+ verify('rawr\n', 'staging.local');
+ }, 3000);
+ });
+ }
+
+ function deploy () {
+ commit(function (code) {
+ t.equal(code, 0);
+ push1();
+ });
+ }
+
+ function verify (msg, host, cb) {
+ var hq = hyperquest('http://localhost:' + port);
+ hq.setHeader('host', host);
+ hq.pipe(concat(function (err, body) {
+ t.equal(msg, String(body));
+ if (cb) cb();
+ }));
+ }
+});
+test(teardown);
View
7 test/setup.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+mkdir -p repo
+cd repo
+cp ../source/package.json ../source/server.js .
+git init .
+git add package.json server.js
+git commit -m'initial files'
View
7 test/source/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "ploy-test-repo",
+ "version": "0.0.0",
+ "scripts": {
+ "start": "node server.js"
+ }
+}
View
7 test/source/server.js
@@ -0,0 +1,7 @@
+var http = require('http');
+var server = http.createServer(function (req, res) {
+ res.end('beep boop\n');
+});
+
+var port = process.argv[2] || process.env.PORT;
+server.listen(port);
View
4 test/teardown.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+if test $(basename $PWD)="test"; then
+ rm -rf repo
+fi

No commit comments for this range

Something went wrong with that request. Please try again.