Skip to content

Commit

Permalink
Fixed for node 0.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Oehlman committed Aug 13, 2012
1 parent 3ab4f99 commit d33941c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
8 changes: 4 additions & 4 deletions lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var Nginx = module.exports = exports = function(dir) {
this.dir = dir;
this.rules = [];
this.conf = path.join(dir, 'rules.json');

if (!path.existsSync(this.conf)){
fs.writeFileSync(this.conf, '');
if (!fs.existsSync(this.conf)){
fs.writeFileSync(this.conf, '{}');
} else {
this.rules = JSON.parse(fs.readFileSync(this.conf));
}
Expand Down Expand Up @@ -123,7 +123,7 @@ Nginx.prototype.update = function(callback) {
callback = function(){}
}

var file = template(routes);
//var file = template(routes);

fs.writeFileSync(path.join(this.dir, 'conf', 'upstream'), upstreamTemplate(routes));
fs.writeFileSync(path.join(this.dir, 'conf', 'location'), locationTemplate(routes));
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

"devDependencies": {
"request": "2.x.x",
"mocha": ">=11.0",
"mocha": ">=1.0",
"request": ">=2.9.0",
"express" : ">=2.5.8"
}
}
}
20 changes: 16 additions & 4 deletions test/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,27 @@ before(function() {
var upstream = path.join(__dirname, 'nginx', 'conf', 'upstream')
, location = path.join(__dirname, 'nginx', 'conf', 'location')

fs.unlinkSync(location);
fs.writeFileSync(location, '');
fs.unlinkSync(upstream);
fs.writeFileSync(upstream, '');
// override the changes
if (fs.existsSync(location)) {
console.log("exists");
fs.unlinkSync(location);
fs.writeFileSync(location, '');
} else {
fs.writeFileSync(location, '');
} // if...else

if (fs.existsSync(upstream)) {
fs.unlinkSync(upstream);
fs.writeFileSync(upstream, '');
} else {
fs.writeFileSync(upstream, '');
}

exec('nginx -p ' + path.join(__dirname, '/nginx/'), function(err, stdout, stderr) {
if (err) {
console.log(err);
}
console.log("nginx dir " + path.join(__dirname, '/nginx/'));
});
server = spawn('node', [path.join(__dirname, 'server', 'server.js')]);
nginx.rules = [];
Expand Down
6 changes: 3 additions & 3 deletions test/server/server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var express = require('express')
, server1 = express.createServer()
, server2 = express.createServer()
, server3 = express.createServer();
, server1 = express()
, server2 = express()
, server3 = express();

// set up three servers for the tests

Expand Down

0 comments on commit d33941c

Please sign in to comment.