diff options
author | Neil Fuller <nfuller@google.com> | 2020-04-30 18:20:56 +0100 |
---|---|---|
committer | Neil Fuller <nfuller@google.com> | 2020-04-30 18:44:28 +0100 |
commit | 2b4b80af97de2c6126456f3fc1415a80cb9268d7 (patch) | |
tree | 6fdf74c5153aa38838ef312f0379c038eedf00ab | |
parent | c4ae49b335bfc5e148e874e097f651e741f86618 (diff) | |
download | timezone-boundary-builder-2b4b80af97de2c6126456f3fc1415a80cb9268d7.tar.gz |
Add a flag to exclude troublesome zones
Tested with:
$ node --max-old-space-size=8192 index.js \
--included_zones America/New_York America/Chicago \
--excluded_zones America/New_York
-rw-r--r-- | index.js | 37 |
1 files changed, 30 insertions, 7 deletions
@@ -24,6 +24,10 @@ const argv = yargs description: 'Include specified zones', type: 'array' }) + .option('excluded_zones', { + description: 'Exclude specified zones', + type: 'array' + }) .option('no_validation', { description: 'Skip validation', type: 'boolean' @@ -35,13 +39,26 @@ const argv = yargs // allow building of only a specified zones let includedZones = [] -if (argv.included_zones) { - var newZoneCfg = {} - includedZones = argv.included_zones - includedZones.forEach((zoneName) => { - newZoneCfg[zoneName] = zoneCfg[zoneName] - }) - zoneCfg = newZoneCfg +let excludedZones = [] +if (argv.included_zones || argv.excluded_zones) { + if (argv.included_zones) { + let newZoneCfg = {} + includedZones = argv.included_zones + includedZones.forEach((zoneName) => { + newZoneCfg[zoneName] = zoneCfg[zoneName] + }) + zoneCfg = newZoneCfg + } + if (argv.excluded_zones) { + let newZoneCfg = {} + excludedZones = argv.excluded_zones + Object.keys(zoneCfg).forEach((zoneName) => { + if (!excludedZones.includes(zoneName)) { + newZoneCfg[zoneName] = zoneCfg[zoneName] + } + }) + zoneCfg = newZoneCfg + } // filter out unneccessary downloads var newOsmBoundarySources = {} @@ -590,6 +607,9 @@ let oceanZones = [ if (includedZones.length > 0) { oceanZones = oceanZones.filter(oceanZone => includedZones.indexOf(oceanZone) > -1) } +if (excludedZones.length > 0) { + oceanZones = oceanZones.filter(oceanZone => excludedZones.indexOf(oceanZone) === -1) +} var addOceans = function (callback) { console.log('adding ocean boundaries') @@ -745,6 +765,9 @@ const autoScript = { if (includedZones.length > 0) { zoneNames = zoneNames.filter(zoneName => includedZones.indexOf(zoneName) > -1) } + if (excludedZones.length > 0) { + zoneNames = zoneNames.filter(zoneName => excludedZones.indexOf(zoneName) === -1) + } fs.writeFile( 'dist/timezone-names.json', JSON.stringify(zoneNames), |