bin.js 459 B

123456789101112131415161718
  1. #!/usr/bin/env node
  2. var fs = require('fs')
  3. var filename = process.argv[2]
  4. var gunzip = require('./')
  5. if (filename === '--help') {
  6. console.log('Usage: gunzip-maybe filename?')
  7. console.log('')
  8. console.log(' cat somefile | gunzip-maybe')
  9. console.log(' gunzip-maybe somefile')
  10. console.log('')
  11. process.exit(0)
  12. }
  13. var input = (!filename || filename === '-') ? process.stdin : fs.createReadStream(filename)
  14. input.pipe(gunzip()).pipe(process.stdout)