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