#!/usr/bin/env node 'use strict'; var tar = require('tar-fs'), fs = require('fs'), path = require('path'), zlib = require('zlib'); if (process.argv.length < 4) { console.error('Usage: tarjs '); process.exit(1); } var dir = process.argv[3]; var cwd = process.argv[2]; console.error('Packing directory "'+ dir +'" from within "' + cwd + '" and stream to stdout'); process.chdir(cwd); var stat = fs.statSync(dir); if (!stat.isDirectory()) throw(dir + ' is not a directory'); var gzipStream = zlib.createGzip({}); tar.pack(path.resolve(dir), { ignore: function (name) { if (name === '.') return true; return false; } }).pipe(gzipStream).pipe(process.stdout);