Skip to content

Commit a46bb5c

Browse files
committed
Don't open the page when starting the server fails
1 parent 3e1f9e9 commit a46bb5c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

instant-markdown-d

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ var server = require('http').createServer(httpHandler),
1515
// directory of the open file!
1616
if (process.env.INSTANT_MARKDOWN_OPEN_TO_THE_WORLD) {
1717
// Listen on any interface.
18-
server.listen(8090);
18+
server.listen(8090, onListening);
1919
} else {
2020
// Listen locally.
21-
server.listen(8090, '127.0.0.1');
21+
server.listen(8090, '127.0.0.1', onListening);
2222
}
2323

2424
var md = new MarkdownIt({
@@ -121,9 +121,11 @@ io.sockets.on('connection', function(sock){
121121
});
122122

123123

124-
if (process.platform.toLowerCase().indexOf('darwin') >= 0){
125-
exec('open -g http://localhost:8090', function(error, stdout, stderr){});
126-
}
127-
else { // assume unix/linux
128-
exec('xdg-open http://localhost:8090', function(error, stdout, stderr){});
124+
function onListening() {
125+
if (process.platform.toLowerCase().indexOf('darwin') >= 0){
126+
exec('open -g http://localhost:8090');
127+
}
128+
else { // assume unix/linux
129+
exec('xdg-open http://localhost:8090');
130+
}
129131
}

0 commit comments

Comments
 (0)