throw if 0 products enabled 💥

This should have been the case previously, but the test didn't fail.
This commit is contained in:
Jannis R 2018-05-28 20:32:10 +02:00
parent 634b044bc5
commit a356a26e2f
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -16,12 +16,14 @@ const createFormatProductsFilter = (profile) => {
if (!isObj(filter)) throw new Error('products filter must be an object') if (!isObj(filter)) throw new Error('products filter must be an object')
filter = Object.assign({}, defaultProducts, filter) filter = Object.assign({}, defaultProducts, filter)
let res = 0 let res = 0, products = 0
for (let product in filter) { for (let product in filter) {
if (!hasProp(filter, product) || filter[product] !== true) continue if (!hasProp(filter, product) || filter[product] !== true) continue
if (!byProduct[product]) throw new Error('unknown product ' + product) if (!byProduct[product]) throw new Error('unknown product ' + product)
products++
for (let bitmask of byProduct[product].bitmasks) res += bitmask for (let bitmask of byProduct[product].bitmasks) res += bitmask
} }
if (products === 0) throw new Error('no products used')
return { return {
type: 'PROD', type: 'PROD',