ForbesLindesay-Unmaintained / tar-pack

Package and un-package modules of some sort (oooh, perhaps you could package JavaScript modules on npm...)
BSD 2-Clause "Simplified" License
37 stars 14 forks source link

Tar Pack

Package and un-package modules of some sort (in tar/gz bundles). This is mostly useful for package managers. Note that it doesn't check for or touch package.json so it can be used even if that's not the way you store your package info.

Build Status Dependency Status NPM version

Installation

$ npm install tar-pack

API

pack(folder|packer, [options])

Pack the folder at folder into a gzipped tarball and return the tgz as a stream. Files ignored by .gitignore will not be in the package.

You can optionally pass a fstream.DirReader directly, instead of folder. For example, to create an npm package, do:

pack(require("fstream-npm")(folder), [options])

Options:

Example:

var write = require('fs').createWriteStream
var pack = require('tar-pack').pack
pack(process.cwd())
  .pipe(write(__dirname + '/package.tar.gz'))
  .on('error', function (err) {
    console.error(err.stack)
  })
  .on('close', function () {
    console.log('done')
  })

unpack(folder, [options,] cb)

Return a stream that unpacks a tarball into a folder at folder. N.B. the output folder will be removed first if it already exists.

The callback is called with an optional error and, as its second argument, a string which is one of:

Basic Options:

Advanced Options (you probably don't need any of these):

Example:

var read = require('fs').createReadStream
var unpack = require('tar-pack').unpack
read(process.cwd() + '/package.tar.gz')
  .pipe(unpack(__dirname + '/package/', function (err) {
    if (err) console.error(err.stack)
    else console.log('done')
  }))

License

BSD