|
1 | | -#!/bin/sh |
2 | | -':' //; exec "`command -v nodejs || command -v node`" "$0" |
| 1 | +#!/usr/bin/env node |
3 | 2 |
|
4 | 3 | var MarkdownIt = require('markdown-it'); |
5 | 4 | var hljs = require('highlight.js'); |
6 | 5 | var server = require('http').createServer(httpHandler), |
7 | 6 | exec = require('child_process').exec, |
8 | 7 | io = require('socket.io').listen(server), |
| 8 | + os = require('os'), |
9 | 9 | send = require('send'); |
10 | 10 |
|
11 | 11 | // WARNING: By setting this environment variable, anyone on your network may |
@@ -141,11 +141,12 @@ io.sockets.on('connection', function(sock){ |
141 | 141 |
|
142 | 142 |
|
143 | 143 | function onListening() { |
144 | | - if (process.platform.toLowerCase().indexOf('darwin') >= 0){ |
145 | | - exec('open -g http://localhost:8090'); |
146 | | - } |
147 | | - else { // assume unix/linux |
148 | | - exec('xdg-open http://localhost:8090'); |
| 144 | + if (os.platform() === 'win32') { |
| 145 | + exec('start /b http://localhost:8090', function(error, stdout, stderr){}); |
| 146 | + } else if (os.platform() === 'darwin') { |
| 147 | + exec('open -g http://localhost:8090', function(error, stdout, stderr){}); |
| 148 | + } else { // assume unix/linux |
| 149 | + exec('xdg-open http://localhost:8090', function(error, stdout, stderr){}); |
149 | 150 | } |
150 | 151 | readAllInput(process.stdin, function(body) { |
151 | 152 | writeMarkdown(body); |
|
0 commit comments