Skip to content

Commit

Permalink
support multiple country codes. closes pelias#360
Browse files Browse the repository at this point in the history
  • Loading branch information
arne-cl committed Jun 24, 2019
1 parent b0b4a52 commit 93fac62
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions import.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ const resolvers = require( './lib/tasks/resolvers' );
const task = require('./lib/tasks/import');
const validateISOCode = require('./lib/validateISOCode');

const isocode = validateISOCode( config.imports.geonames.countryCode );
const filename = isocode === 'ALL' ? 'allCountries' : isocode;
const source = resolvers.selectSource( filename );
const countrycode = config.imports.geonames.countryCode;

task( source );
if (typeof countrycode === 'string') {
const isocode = validateISOCode( countrycode );
const filename = isocode === 'ALL' ? 'allCountries' : isocode;
const source = resolvers.selectSource( filename );
task( source );
} else if (Array.isArray(countrycode)) {
for (var i in countrycode) {
const filename = validateISOCode( countrycode[i] );
const source = resolvers.selectSource( filename );
task( source );
}
} else {
throw new Error('imports.geonames.countryCode must be either a string ' +
'or an array of strings.');
}

0 comments on commit 93fac62

Please sign in to comment.