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 { MONGOHQ_URL } = process.env;
const { MONGOHQ_URL, NODE_ENV: env } = process.env;
function handleError(err, client) {
if (err) {
@ -26,6 +26,7 @@ function handleError(err, client) {
}
}
if (env !== 'production') {
MongoClient.connect(
MONGOHQ_URL,
{ useNewUrlParser: true },
@ -50,6 +51,7 @@ MongoClient.connect(
.catch(err => handleError(err, client));
}
);
}
function stubArticles(numberOfArticles = 1) {
return new Array(numberOfArticles).fill('').map(() => generateArticle());