Skip to content

Commit

Permalink
Tweak code style
Browse files Browse the repository at this point in the history
  • Loading branch information
lifesinger committed Apr 23, 2013
1 parent 3d23850 commit bb6332f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ build_all:

test: test_node test_local test_http

test_http:
@node tools/server.js . phantomjs tools/phantom.js http://127.0.0.1:9012/tests/runner.html?console
test_node:
@node tests/node-runner.js

test_local:
@phantomjs tools/phantom.js tests/runner.html?console

test_node:
@node tests/node-runner.js
test_http:
@node tools/server.js . phantomjs tools/phantom.js http://127.0.0.1:9012/tests/runner.html?console

totoro:
@totoro-test --adapter=tests/totoro-adapter.js
Expand Down
57 changes: 29 additions & 28 deletions tools/server.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
var fs = require('fs');
var http = require('http');
var print = require('util').print;
var spawn = require('child_process').spawn;
var static = require('node-static');

var fs = require('fs')
var http = require('http')
var print = require('util').print
var spawn = require('child_process').spawn
var Static = require('node-static')


function createServer(dir, cmd) {
dir = dir || '.';
dir = dir || '.'

// Server Start
var file = new static.Server(fs.realpathSync(dir));
var file = new Static.Server(fs.realpathSync(dir))

var server = http.createServer(function(request, response) {
request.addListener('end', function() {
file.serve(request, response);
}).resume();
});
request.addListener('end',function() {
file.serve(request, response)
}).resume()
})

server.listen(9012, function() {
if (cmd) {
var args = cmd.split(' ');
var args = cmd.split(' ')
args = args.map(function(arg) {
return arg.trim();
});
return arg.trim()
})
args = args.filter(function(arg) {
return arg.length;
});
var runner = spawn(args[0], args.slice(1));
return arg.length
})
var runner = spawn(args[0], args.slice(1))
runner.stdout.on('data', function(data) {
print(data.valueOf());
});
print(data.valueOf())
})
runner.on('exit', function(code) {
if (code === 127) {
print(cmd + ' not available');
print(cmd + ' not available')
}
server.close();
process.exit(code);
});
server.close()
process.exit(code)
})
}
});
})
}

var dir = process.argv[2] || '.';
var cmd = process.argv.slice(3);
createServer(dir, cmd.join(' '));
var dir = process.argv[2] || '.'
var cmd = process.argv.slice(3)
createServer(dir, cmd.join(' '))

0 comments on commit bb6332f

Please sign in to comment.