Skip to content

Commit e7be945

Browse files
authored
Add support for reading files (#127)
1 parent c3eee6c commit e7be945

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

json-to-go.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ if (typeof module != 'undefined') {
459459
const json = Buffer.concat(bufs).toString('utf8')
460460
process.stdout.write(jsonToGo(json).go)
461461
})
462+
} else if (process.argv.length === 3) {
463+
const fs = require('node:fs');
464+
const json = fs.readFileSync(process.argv[2], 'utf8');
465+
console.log(jsonToGo(json).go)
462466
} else {
463467
process.stdin.on('data', function(buf) {
464468
const json = buf.toString('utf8')

0 commit comments

Comments
 (0)