-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
31 lines (27 loc) · 964 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var http = require('http');
var express = require('express');
var server = express();
var configUtils = require('./lib/configUtils');
server.use(express.static(__dirname));
var port = process.env.PORT || 1337;
server.listen(port, function() {
console.log('listening on port ' + port);
//var err = new Error('This error won't break the application...')
//throw err
});
var timeFormatter = function () {
return new Date().toString() + ": ";
};
if(!process.env.configLoaded){
configUtils.load();
var execFile = require('child_process').exec;
var cmd = "\"./node_modules/.bin/grunt\" browserify:example";
execFile(cmd, function(error, stdout, stderr) {
configUtils.save(timeFormatter() + stdout, './info.log');
configUtils.save(timeFormatter() + stderr, './error.log');
if (error != null) {
configUtils.save('exec error: ' + timeFormatter() + error, './error.log');
}
process.env.configLoaded = true;
});
}