Created
May 26, 2015 01:58
-
-
Save azu/aed39e9917e3085439a2 to your computer and use it in GitHub Desktop.
コマンドラインで標準入力とファイル名指定をするパターン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var doSome = require('../').doSome; | |
var concat = require('concat-stream'); | |
var fs = require('fs'); | |
var file = process.argv[2]; | |
var input = file && file !== '-' | |
? fs.createReadStream(process.argv[2]) | |
: process.stdin | |
; | |
input.pipe(concat(function (buf) { | |
console.log(doSome(buf.toString('utf8'))); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment