Suppress logging when running tests

master
Mark Moffat 2019-11-09 10:57:20 +10:30
parent a7e09f3d56
commit 0991405072
2 changed files with 15 additions and 5 deletions

2
app.js
View File

@ -419,7 +419,9 @@ initDb(config.databaseConnectionString, async (err, db) => {
try{ try{
await app.listen(app.get('port')); await app.listen(app.get('port'));
app.emit('appStarted'); app.emit('appStarted');
if(process.env.NODE_ENV !== 'test'){
console.log(colors.green('expressCart running on host: http://localhost:' + app.get('port'))); console.log(colors.green('expressCart running on host: http://localhost:' + app.get('port')));
}
}catch(ex){ }catch(ex){
console.error(colors.red('Error starting expressCart app:' + err)); console.error(colors.red('Error starting expressCart app:' + err));
process.exit(2); process.exit(2);

View File

@ -31,7 +31,9 @@ const indexProducts = (app) => {
}); });
app.productsIndex = productsIndex; app.productsIndex = productsIndex;
if(process.env.NODE_ENV !== 'test'){
console.log(colors.cyan('- Product indexing complete')); console.log(colors.cyan('- Product indexing complete'));
}
resolve(); resolve();
}); });
}); });
@ -67,7 +69,9 @@ const indexCustomers = (app) => {
}); });
app.customersIndex = customersIndex; app.customersIndex = customersIndex;
if(process.env.NODE_ENV !== 'test'){
console.log(colors.cyan('- Customer indexing complete')); console.log(colors.cyan('- Customer indexing complete'));
}
resolve(); resolve();
}); });
}); });
@ -103,7 +107,9 @@ const indexOrders = (app, cb) => {
}); });
app.ordersIndex = ordersIndex; app.ordersIndex = ordersIndex;
if(process.env.NODE_ENV !== 'test'){
console.log(colors.cyan('- Order indexing complete')); console.log(colors.cyan('- Order indexing complete'));
}
resolve(); resolve();
}); });
}); });
@ -120,7 +126,9 @@ const fixProductDates = (products) => {
// start indexing products and orders // start indexing products and orders
const runIndexing = (app) => { const runIndexing = (app) => {
if(process.env.NODE_ENV !== 'test'){
console.info(colors.yellow('Setting up indexes..')); console.info(colors.yellow('Setting up indexes..'));
}
return Promise.all([ return Promise.all([
indexProducts(app), indexProducts(app),