Skip to content

Commit

Permalink
feat: Add --pretty flag to print formatted json
Browse files Browse the repository at this point in the history
  • Loading branch information
dworthen committed Feb 27, 2018
1 parent 1459c50 commit f119924
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bin/js-yaml-front.js
Expand Up @@ -8,6 +8,7 @@ program
.version(package.version, '-v, --version')
.usage('[options] <string>')
.option('-c, --content [name]', 'set the property name for the files contents [__content]')
.option('--pretty', 'prints the json output with spaces.')
.on('--help', function() {
console.log('');
console.log(' Examples')
Expand Down Expand Up @@ -40,6 +41,8 @@ if (program.args.length > 0) {
}

function processData(data) {
process.stdout.write(JSON.stringify(yamlFront.loadFront(data,
{ contentKeyName: program.content || '__content' }), undefined, 2));
console.log(JSON.stringify(yamlFront.safeLoadFront(data,
{ contentKeyName: program.content || '__content' }),
undefined,
program.pretty ? 2 : 0));
}

0 comments on commit f119924

Please sign in to comment.