使用nodejs 来压缩整个目录

var fstream = require('fstream'),
tar = require('tar'),
zlib = require('zlib');

fstream.Reader({ 'path': 'sub', 'type': 'Directory' }) /* Read the source directory */
.pipe(tar.Pack()) /* Convert the directory to a .tar file */
.pipe(zlib.Gzip()) /* Compress the .tar file */
.pipe(fstream.Writer({ 'path': '../output/compressed_folder.zip' })); /* Give the output file name */
posted @ 2015-04-17 22:23  诺唯  阅读(2391)  评论(0编辑  收藏  举报