fix: Add 'production' check
This commit is contained in:
committed by
mrugesh mohapatra
parent
fbee89b345
commit
01097385d6
@ -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,6 +26,7 @@ function handleError(err, client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (env !== 'production') {
|
||||||
MongoClient.connect(
|
MongoClient.connect(
|
||||||
MONGOHQ_URL,
|
MONGOHQ_URL,
|
||||||
{ useNewUrlParser: true },
|
{ useNewUrlParser: true },
|
||||||
@ -50,6 +51,7 @@ 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());
|
||||||
|
Reference in New Issue
Block a user