xml2json 426 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env node
  2. var xml2json = require('../');
  3. var pkg = require('../package.json');
  4. var xml = '';
  5. var args = process.argv.slice(2)
  6. var arg = args[0]
  7. if (arg == '--version') {
  8. console.log(pkg.version)
  9. process.exit(0)
  10. }
  11. process.stdin.on('data', function (data) {
  12. xml += data;
  13. });
  14. process.stdin.resume();
  15. process.stdin.on('end', function () {
  16. json = xml2json.toJson(xml)
  17. process.stdout.write(json + '\n')
  18. });