Skip to content

Commit

Permalink
Rearrange logic in output_mapping
Browse files Browse the repository at this point in the history
`process.exit` can truncate long output in certain node versions, see
these tickets:

nodejs/node#3669
nodejs/node#3170
nodejs/node#2972 (comment)

fixes #161
  • Loading branch information
orangejulius committed Aug 4, 2016
1 parent cb3158d commit db3ce4a
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 db3ce4a

Please sign in to comment.