Skip to content

Commit

Permalink
Merge pull request #9 from isaacs/browseropen
Browse files Browse the repository at this point in the history
Automatically try to open the user's default browser
  • Loading branch information
coreh committed Sep 18, 2011
2 parents f0aa410 + 826a202 commit 112745d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions server.js
@@ -1,6 +1,7 @@
var express = require('express');
var sockeio = require('socket.io')
var project = require('./project.js')
var child_process = require('child_process')

var server = express.createServer();

Expand Down Expand Up @@ -29,7 +30,16 @@ exports.listen = function(port) {
});
});

console.log("Nide listening on port " + port + ".");
console.log("Nide running at http://localhost:" + port);
var nideUrl = "http://localhost:" + port;
var browser;
switch (process.platform) {
case "win32": browser = "start"; break;
case "darwin": browser = "open"; break;
default: browser = "google-chrome"; break;
}
// if this fails, it'll just exit with a non-zero code.
child_process.spawn(browser, [nideUrl]);

io.sockets.on('connection', function(socket) {
project.list()
Expand Down Expand Up @@ -161,4 +171,4 @@ exports.listen = function(port) {
})
})

}
}

0 comments on commit 112745d

Please sign in to comment.