From a356a26e2fbd34940d7b3634b1c0552d41d0108b Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 28 May 2018 20:32:10 +0200 Subject: [PATCH] throw if 0 products enabled :boom: This should have been the case previously, but the test didn't fail. --- format/products-filter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/format/products-filter.js b/format/products-filter.js index 8ee8ffca..e4252f8f 100644 --- a/format/products-filter.js +++ b/format/products-filter.js @@ -16,12 +16,14 @@ const createFormatProductsFilter = (profile) => { if (!isObj(filter)) throw new Error('products filter must be an object') filter = Object.assign({}, defaultProducts, filter) - let res = 0 + let res = 0, products = 0 for (let product in filter) { if (!hasProp(filter, product) || filter[product] !== true) continue if (!byProduct[product]) throw new Error('unknown product ' + product) + products++ for (let bitmask of byProduct[product].bitmasks) res += bitmask } + if (products === 0) throw new Error('no products used') return { type: 'PROD',