Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/cli-streams
A pair of streams - process.stdin/stdout or filestreams depending on cli option overrides
https://github.com/binocarlos/cli-streams
Last synced: 11 days ago
JSON representation
A pair of streams - process.stdin/stdout or filestreams depending on cli option overrides
- Host: GitHub
- URL: https://github.com/binocarlos/cli-streams
- Owner: binocarlos
- License: mit
- Created: 2014-06-29T14:03:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-06-29T14:04:43.000Z (over 10 years ago)
- Last Synced: 2024-11-07T12:53:12.670Z (13 days ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cli-streams
===========A pair of streams - process.stdin/stdout or filestreams depending on cli option overrides
## installation
```
$ npm install cli-streams
```## usage
A module to use when a cli program will accept stdin and write to stdout but can optionally redirect either to a filestream.
```js
var args = require('minimist').parse(process.argv, {
i:'input',
o:'output'
})
var resolve = require('cli-path-resolve')
var clistreams = require('cli-streams')
var through = require('through2')var streams = clistreams(resolve(args.input), resolve(args.output))
streams.input.pipe(through(function(chunk, enc, next){
this.push(chunk.toString().toUpperCase())
})).pipe(streams.output)
```## api
### `var pair = streams(inputPath, outputPath)`
return an object with 2 streams:
* input - either process.stdin or a file readStream if input param exists
* output - either process.stdout or a file readStream if input param exists### license
MIT