Comparing version 1.3.0 to 1.4.0
34
cli.js
@@ -7,2 +7,3 @@ #!/usr/bin/env node | ||
var createWriteStream = require('fs').createWriteStream | ||
var PassThrough = require('stream').PassThrough | ||
@@ -18,2 +19,21 @@ var eventToPromise = require('event-to-promise') | ||
function createInputStream (path) { | ||
return path === undefined || path === '-' | ||
? process.stdin | ||
: createReadStream(path) | ||
} | ||
function createOutputStream (path) { | ||
if (path !== undefined && path !== '-') { | ||
return createWriteStream(path) | ||
} | ||
// introduce a through stream because stdout is not a normal stream! | ||
var stream = new PassThrough() | ||
stream.pipe(process.stdout) | ||
return stream | ||
} | ||
// =================================================================== | ||
var usage = [ | ||
@@ -43,4 +63,2 @@ 'Usage: ' + pkg.name + ' [OPTIONS] [<input file> [<output file>]]', | ||
function main (args) { | ||
var _ref | ||
args = minimist(args, { | ||
@@ -62,12 +80,4 @@ boolean: ['dynamic-typing', 'help', 'tsv'], | ||
var input = (_ref = args._[0]) && (_ref !== '-') | ||
? createReadStream(_ref) | ||
: process.stdin | ||
var output = (_ref = args._[1]) && (_ref !== '-') | ||
? createWriteStream(_ref) | ||
: process.stdout | ||
return eventToPromise(pump([ | ||
input, | ||
createInputStream(args._[0]), | ||
csv2json({ | ||
@@ -77,3 +87,3 @@ dynamicTyping: args['dynamic-typing'], | ||
}), | ||
output | ||
createOutputStream(args._[0]) | ||
]), 'finish') | ||
@@ -80,0 +90,0 @@ } |
{ | ||
"name": "csv2json", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"license": "ISC", | ||
@@ -32,15 +32,15 @@ "description": "Stream and CLI to convert CSV to JSON", | ||
"csv-parser": "^1.11.0", | ||
"event-to-promise": "^0.7.0", | ||
"exec-promise": "^0.6.1", | ||
"husky": "^0.13.1", | ||
"event-to-promise": "^0.8.0", | ||
"exec-promise": "^0.7.0", | ||
"minimist": "^1.2.0", | ||
"pump": "^1.0.2", | ||
"pumpify": "^1.3.5", | ||
"through2": "^2.0.3", | ||
"strip-bom-stream": "^3.0.0" | ||
"strip-bom-stream": "^3.0.0", | ||
"through2": "^2.0.3" | ||
}, | ||
"devDependencies": { | ||
"dependency-check": "^2.8.0", | ||
"jest": "^19.0.2", | ||
"standard": "^8.6.0" | ||
"dependency-check": "^2.9.1", | ||
"husky": "^0.14.3", | ||
"jest": "^21.2.1", | ||
"standard": "^10.0.3" | ||
}, | ||
@@ -47,0 +47,0 @@ "scripts": { |
@@ -34,2 +34,5 @@ # csv2json [](https://travis-ci.org/julien-f/csv2json) | ||
-t, --tsv | ||
Use tab as separator, overrides separator flag. | ||
<input file> | ||
@@ -36,0 +39,0 @@ CSV file to read data from. |
6528
8
132
78
4
+ Addedevent-to-promise@0.8.0(transitive)
+ Addedexec-promise@0.7.0(transitive)
- Removedhusky@^0.13.1
- Removedci-info@1.6.0(transitive)
- Removedevent-to-promise@0.7.0(transitive)
- Removedexec-promise@0.6.1(transitive)
- Removedfind-parent-dir@0.3.1(transitive)
- Removedhusky@0.13.4(transitive)
- Removedis-ci@1.2.1(transitive)
- Removednormalize-path@1.0.0(transitive)
Updatedevent-to-promise@^0.8.0
Updatedexec-promise@^0.7.0