Skip to content

Commit

Permalink
fix: Merge pull request #162 from pelias/fix_output_mapping
Browse files Browse the repository at this point in the history
Rearrange logic in output_mapping
  • Loading branch information
orangejulius authored Aug 18, 2016
2 parents c7f6772 + db3ce4a commit 2b1316e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions scripts/output_mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ var schema = require('../schema');
var _index = ( process.argv.length > 3 ) ? process.argv[3] : config.schema.indexName;
var _type = ( process.argv.length > 2 ) ? process.argv[2] : null; // get type from cli args

if( !_type ){
// print out mapping for just one type
if ( _type ) {
var mapping = schema.mappings[_type];
if( !mapping ){
console.error( 'could not find a mapping in the schema file for', _index+'/'+_type );
process.exit(1);
}
console.log( JSON.stringify( mapping, null, 2 ) );
//print out the entire schema mapping
} else {
console.log( JSON.stringify( schema, null, 2 ) );
process.exit(0);
}

var mapping = schema.mappings[_type];
if( !mapping ){
console.error( 'could not find a mapping in the schema file for', _index+'/'+_type );
process.exit(1);
}

console.log( JSON.stringify( mapping, null, 2 ) );

0 comments on commit 2b1316e

Please sign in to comment.