xonecas.io
142
St

startsInvasion / files

startsInvasion / libs / node_modules / reqwest / make / tests.js

747 bytes
1var http = require('http'),
2    exec = require('child_process').exec,
3    fs = require('fs'),
4    Connect = require('connect'),
5    dispatch = require('dispatch'),
6    mime = require('mime');
7
8var routes = {
9  '/': function (req, res) {
10    res.write(fs.readFileSync('./tests/tests.html', 'utf8'));
11    res.end();
12  },
13
14  '(([a-zA-Z0-9_\\-\\/]+)\\.(css|js|json|html)$)': function (req, res, m, file, ext) {
15    res.writeHead(200, {'Content-Type': mime.lookup(ext)});
16    var asset = fs.readFileSync('./' + file + '.' + ext);
17    res.write(asset);
18    res.end();
19  }
20};
21
22Connect.createServer(dispatch(routes)).listen(1234, '127.0.0.1');
23
24exec('open http://localhost:1234', function () {
25  console.log('opening tests at http://localhost:1234');
26});