Permalink
Browse files

Allow manually setting of port on command line

  • Loading branch information...
1 parent 39c5fdd commit 0ba67b124f910c5229cb8793d82caf3f96156255 Patrick Boos committed Dec 3, 2013
Showing with 18 additions and 3 deletions.
  1. +14 −1 bin/easymock
  2. +3 −2 lib/easymock.js
  3. +1 −0 package.json
View
@@ -1,5 +1,18 @@
#!/usr/bin/env node
+var program = require('commander');
+
+program
+ .version(require('../package').version)
+ .option('-p, --port [port]', 'Set port. Default is 3000.', 3000)
+ .parse(process.argv);
+
var MockServer = require('../index').MockServer;
-var mock = new MockServer();
+var options = undefined;
+if (program.port) {
+ options = {
+ port: parseInt(program.port)
+ };
+}
+var mock = new MockServer(options);
mock.start();
View
@@ -116,7 +116,8 @@ MockServer.prototype.startMock = function() {
app.delete('*', this.handleAnyRequest);
app.put('*', this.handleAnyRequest);
- this.mock_server = app.listen(3001);
+ this.mock_server = app.listen(this.options.port + 1);
+ console.log(this.options.port + 1);
};
MockServer.prototype.startProxy = function() {
@@ -150,7 +151,7 @@ MockServer.prototype.startProxy = function() {
} else {
proxy.proxyRequest(req, res, {
host: 'localhost',
- port: 3001,
+ port: self.options.port + 1,
buffer: buffer
});
}
View
@@ -19,6 +19,7 @@
, "sqlite3": "2.1.17"
, "moment": "2.0.0"
, "marked": "0.2.10"
+ , "commander": "2.1.0"
}
, "devDependencies": {
"chai": "1.1.0"

0 comments on commit 0ba67b1

Please sign in to comment.