packer.js 488 B

123456789101112131415161718192021222324
  1. var tar = require("../tar.js")
  2. , fstream = require("fstream")
  3. , fs = require("fs")
  4. var dirDest = fs.createWriteStream('dir.tar')
  5. function onError(err) {
  6. console.error('An error occurred:', err)
  7. }
  8. function onEnd() {
  9. console.log('Packed!')
  10. }
  11. var packer = tar.Pack({ noProprietary: true })
  12. .on('error', onError)
  13. .on('end', onEnd);
  14. // This must be a "directory"
  15. fstream.Reader({ path: __dirname, type: "Directory" })
  16. .on('error', onError)
  17. .pipe(packer)
  18. .pipe(dirDest)