Skip to content

Commit bee0c61

Browse files
author
Luciano Mammino
committed
WIP
1 parent 8dde094 commit bee0c61

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
# x2j-cli
2-
Node.js command line script to convert xml input into json output (can be piped easily)
2+
3+
Node.js command line script to convert XML input into JSON output (can be piped easily)
4+
5+
6+
## Install
7+
8+
It requires Node (0.12 or higher) and Npm (2 or higher):
9+
10+
```bash
11+
npm install --global x2j-cli
12+
```

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ stdin.on('data', function (chunk) {
1818
stdin.on('end', function () {
1919
xml2js.parseString(content, (err, parsedData) => {
2020
if (err) {
21-
return console.error(err);
21+
console.error(err);
22+
process.exit(1);
2223
}
2324
var outputJSON = JSON.stringify(parsedData, null, 2);
2425
stdout.write(outputJSON);
2526
stdout.write('\n');
27+
process.exit(0);
2628
});
2729
});

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "x2j-cli",
33
"version": "1.0.0",
44
"description": "Node.js command line script to convert xml input into json output (can be piped easily)",
5+
"engines" : {
6+
"node" : ">=0.12"
7+
},
58
"main": "index.js",
69
"bin": {
710
"x2j": "./index.js"

0 commit comments

Comments
 (0)