Skip to content

Commit 7b269ff

Browse files
authored
Merge pull request #16 from greenkeeperio/fixes/properly-ignore-empty-urls
fix: properly filter empty URLs
2 parents 03143e7 + 94e95b1 commit 7b269ff

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
const amqp = require('amqplib')
22
const redis = require('redis')
3-
const isEmpty = require('lodash').isEmpty
43

54
const env = require('./lib/env')
65
const {parseRegistryUrl, checkFollower, startChanges} = require('./lib/follow')
7-
const isNotEmpty = (value) => !isEmpty(value)
86

97
;(async () => {
108
const conn = await amqp.connect(env.AMQP_URL)
@@ -14,7 +12,7 @@ const isNotEmpty = (value) => !isEmpty(value)
1412
})
1513
const client = redis.createClient(env.REDIS_URL)
1614

17-
env.REGISTRY_URLS.filter(isNotEmpty).forEach(registryUrl => {
15+
env.REGISTRY_URLS.forEach(registryUrl => {
1816
const registry = parseRegistryUrl(registryUrl)
1917
const start = startChanges.bind(null, {
2018
channel,

lib/env.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
const envalid = require('envalid')
2+
const isEmpty = require('lodash').isEmpty
23
const {str, url, json, bool, num} = envalid
34

5+
const isNotEmpty = (value) => !isEmpty(value)
6+
47
const urlArray = envalid.makeValidator(x => {
58
const urls = json()._parse(x)
69
if (!Array.isArray(urls)) throw new Error('JSON is no array')
7-
return urls.map(url()._parse).filter(Boolean)
10+
return urls.filter(isNotEmpty).map(url()._parse)
811
})
912

1013
const environmentConfig = {

0 commit comments

Comments
 (0)