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