Skip invariants in test env

This commit is contained in:
MICHAEL JACKSON 2017-09-13 08:35:25 -07:00
parent 293786d182
commit f4f0c59552
2 changed files with 10 additions and 8 deletions

View File

@ -1,5 +1,5 @@
require('isomorphic-fetch')
const warning = require('warning')
const invariant = require('invariant')
const gunzip = require('gunzip-maybe')
const ndjson = require('ndjson')
@ -7,12 +7,12 @@ const CloudflareAPIURL = 'https://api.cloudflare.com'
const CloudflareEmail = process.env.CLOUDFLARE_EMAIL
const CloudflareKey = process.env.CLOUDFLARE_KEY
warning(
invariant(
CloudflareEmail,
'Missing the $CLOUDFLARE_EMAIL environment variable'
)
warning(
invariant(
CloudflareKey,
'Missing the $CLOUDFLARE_KEY environment variable'
)

View File

@ -9,9 +9,6 @@ const packageURL = require('./middleware/packageURL')
const fetchFile = require('./middleware/fetchFile')
const serveFile = require('./middleware/serveFile')
const createSearchServer = require('./createSearchServer')
const createStatsServer = require('./createStatsServer')
morgan.token('fwd', function (req) {
return req.get('x-forwarded-for').replace(/\s/g, '')
})
@ -48,8 +45,13 @@ function createApp() {
maxAge: '365d'
}))
if (process.env.NODE_ENV !== 'test') {
const createSearchServer = require('./createSearchServer')
app.use('/_search', createSearchServer())
const createStatsServer = require('./createStatsServer')
app.use('/_stats', createStatsServer())
}
app.use('/',
packageURL,