removed some code smells and made nodejs logger expleciet.
This commit is contained in:
parent
d4f681e28c
commit
58142e9300
6 changed files with 118 additions and 68 deletions
|
|
@ -10,6 +10,7 @@ var morgan = require('morgan');
|
|||
var UglifyJS = require("uglify-js");
|
||||
var Hashes = require('jshashes');
|
||||
var minify = require('minify');
|
||||
var logger = require('console');
|
||||
|
||||
var appPath = '/test'; // dynamic context path for version or proxy/etc of server app.
|
||||
var clientResourcesWeb = [];
|
||||
|
|
@ -56,14 +57,23 @@ var fetchHashResources = function(fetchList, cb) {
|
|||
var createClientResourceFetchList = function() {
|
||||
var fetchList = [];
|
||||
for (var clientResourceIdxJs in clientResources.js) {
|
||||
if (!clientResources.js.hasOwnProperty(clientResourceIdxJs)) {
|
||||
continue;
|
||||
}
|
||||
var urlJs = clientResources.js[clientResourceIdxJs];
|
||||
fetchList.push({url:urlJs,type:'js'});
|
||||
}
|
||||
for (var clientResourceIdxCss in clientResources.css) {
|
||||
if (!clientResources.css.hasOwnProperty(clientResourceIdxCss)) {
|
||||
continue;
|
||||
}
|
||||
var urlCss = clientResources.css[clientResourceIdxCss];
|
||||
fetchList.push({url:urlCss,type:'css'});
|
||||
}
|
||||
for (var clientResourceIdxCssData in clientResources.dss) {
|
||||
if (!clientResources.dss.hasOwnProperty(clientResourceIdxCssData)) {
|
||||
continue;
|
||||
}
|
||||
var urlCssData = clientResources.cssData[clientResourceIdxCssData];
|
||||
fetchList.push({url:urlCssData,type:'dss'});
|
||||
}
|
||||
|
|
@ -115,14 +125,15 @@ server.get(appPath+'/example-ui', renderIndex());
|
|||
server.get('/', function (req, res) {res.redirect(appPath);});
|
||||
|
||||
server.listen(httpPort);
|
||||
console.info('Server started on port '+httpPort);
|
||||
logger.info('Server started on port '+httpPort);
|
||||
|
||||
fetchHashResources(createClientResourceFetchList(), function(err) {
|
||||
if (err !== null) {
|
||||
console.log('Fatal error '+err);
|
||||
logger.log('Fatal error '+err);
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log('Total assets build: '+clientResourcesWeb.length);
|
||||
logger.log('Total assets build: '+clientResourcesWeb.length);
|
||||
logger.log('Server boot done.');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue