Skip to content

Commit fa21630

Browse files
committed
Address issue #17: support node cli & require
1 parent f5cbf55 commit fa21630

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

json-to-go.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,14 @@ function jsonToGo(json, typename)
231231
});
232232
}
233233
}
234+
235+
if (typeof module != 'undefined') {
236+
if (!module.parent) {
237+
process.stdin.on('data', function(buf) {
238+
var json = buf.toString('utf8')
239+
console.log(jsonToGo(json).go)
240+
})
241+
} else {
242+
module.exports = jsonToGo
243+
}
244+
}

0 commit comments

Comments
 (0)