Skip to content

Commit

Permalink
Address issue mholt#17: support node cli & require
Browse files Browse the repository at this point in the history
  • Loading branch information
ShevaXu committed Feb 10, 2017
1 parent f5cbf55 commit fa21630
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions json-to-go.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,14 @@ function jsonToGo(json, typename)
});
}
}

if (typeof module != 'undefined') {
if (!module.parent) {
process.stdin.on('data', function(buf) {
var json = buf.toString('utf8')
console.log(jsonToGo(json).go)
})
} else {
module.exports = jsonToGo
}
}

0 comments on commit fa21630

Please sign in to comment.