fix: Add 'production' check

This commit is contained in:
Bouncey
2018-11-09 16:07:52 +00:00
committed by mrugesh mohapatra
parent fbee89b345
commit 01097385d6

View File

@ -9,7 +9,7 @@ const debug = require('debug');
const log = debug('fcc:tools:seedNewsArticles'); const log = debug('fcc:tools:seedNewsArticles');
const { MONGOHQ_URL } = process.env; const { MONGOHQ_URL, NODE_ENV: env } = process.env;
function handleError(err, client) { function handleError(err, client) {
if (err) { if (err) {
@ -26,7 +26,8 @@ function handleError(err, client) {
} }
} }
MongoClient.connect( if (env !== 'production') {
MongoClient.connect(
MONGOHQ_URL, MONGOHQ_URL,
{ useNewUrlParser: true }, { useNewUrlParser: true },
async function(err, client) { async function(err, client) {
@ -49,7 +50,8 @@ MongoClient.connect(
}) })
.catch(err => handleError(err, client)); .catch(err => handleError(err, client));
} }
); );
}
function stubArticles(numberOfArticles = 1) { function stubArticles(numberOfArticles = 1) {
return new Array(numberOfArticles).fill('').map(() => generateArticle()); return new Array(numberOfArticles).fill('').map(() => generateArticle());