Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 44ec8f8

Browse files
committed
add executable
1 parent 976a158 commit 44ec8f8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

bin/xml2json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env node
2+
3+
var xml2json = require('../');
4+
var pkg = require('../package.json');
5+
6+
var xml = '';
7+
8+
var args = process.argv.slice(2)
9+
var arg = args[0]
10+
11+
if (arg == '--version') {
12+
console.log(pkg.version)
13+
process.exit(0)
14+
}
15+
16+
process.stdin.on('data', function (data) {
17+
xml += data;
18+
});
19+
20+
process.stdin.resume();
21+
22+
process.stdin.on('end', function () {
23+
json = xml2json.toJson(xml)
24+
process.stdout.write(json + '\n')
25+
});
26+

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
],
1111
"dependencies": {
1212
"node-expat": "2.0.0"
13+
},
14+
"bin": {
15+
"xml2json": "bin/xml2json"
1316
}
1417
}
1518

0 commit comments

Comments
 (0)