bin.js 367 B

123456789101112131415
  1. #!/usr/bin/env node
  2. var fs = require('fs')
  3. var shasum = require('.')
  4. var input = process.argv[2]
  5. if (input && input !== '-') {
  6. console.log(shasum(fs.readFileSync(input)))
  7. } else {
  8. var buffers = []
  9. process.stdin.on('data', function (chunk) { buffers.push(chunk) })
  10. process.stdin.on('end', function () {
  11. console.log(shasum(Buffer.concat(buffers)))
  12. })
  13. }