Evan Siroky | 081c8e4 | 2017-05-29 14:53:52 -0700 | [diff] [blame^] | 1 | const osmBoundarySources = require('./osmBoundarySources.json') |
| 2 | const zoneCfg = require('./timezones.json') |
| 3 | |
| 4 | let numErrors = 0 |
| 5 | |
| 6 | const sourcesUsage = {} |
| 7 | Object.keys(osmBoundarySources).forEach(source => { |
| 8 | sourcesUsage[source] = false |
| 9 | }) |
| 10 | |
| 11 | Object.keys(zoneCfg).forEach(zone => { |
| 12 | zoneCfg[zone].forEach(operation => { |
| 13 | if (operation.source === 'overpass') { |
| 14 | // check if source is defined |
| 15 | if (!osmBoundarySources[operation.id]) { |
| 16 | numErrors++ |
| 17 | |
| 18 | console.error(`No osmBoundarySources config found for entry: ${operation.id}`) |
| 19 | } else { |
| 20 | sourcesUsage[operation.id] = true |
| 21 | } |
| 22 | } |
| 23 | }) |
| 24 | }) |
| 25 | |
| 26 | // check for sources not used in timezone building |
| 27 | Object.keys(sourcesUsage).forEach(source => { |
| 28 | if (!sourcesUsage[source]) { |
| 29 | numErrors++ |
| 30 | console.error(`osmBoundarySources config "${source}" is never used in timezone boundary building`) |
| 31 | } |
| 32 | }) |
| 33 | |
| 34 | if (numErrors > 0) { |
| 35 | console.error(`${numErrors} errors found`) |
| 36 | process.exit(1) |
| 37 | } else { |
| 38 | console.log('No linting errors!') |
| 39 | } |