1.2.0 • Published 8 years ago

tarball-unpacker v1.2.0

Weekly downloads
3
License
GPL-2.0
Repository
github
Last release
8 years ago

tarball-unpacker

Coverage Status Build Status Dependency Status devDependency Status js-standard-style semantic-release

Tarball unpacker tool for Node.js

API

  • extractFromFile extracts a tarball file into a target directory.
import unpacker from 'tarball-unpacker'

// Specify a file and target directory
unpacker
  .extractFromFile('/path/to/file.tgz', '/tmp/destination')
  .then((files) => {
    console.log(files) // An array of unpacked paths to files
    console.log('Done!')
  })

Listen to each file extracted:

import unpacker from 'tarball-unpacker'

unpacker
  .configure({
    silent: true,
    onExtract: (entry) => {
      console.log(entry.path)
    }
  })
  .extractFromFile('/path/to/file.tgz', '/tmp/destination')
  .then(() => {
    console.log('Done!')
  })
  .catch((err) => {
    console.log('Something went wrong ', err)
  })
  • extractFromURL extracts a tarball from URL into a target directory.
import unpacker from 'tarball-unpacker'

// Specify a URL and target directory
unpacker
  .extractFromURL('http://www.arkaitzgarro.com/tarball.tgz', '/tmp/destination')
  .then((files) => {
    console.log(files) // An array of unpacked paths to files
    console.log('Done!')
  })
  .catch((err) => {
    console.log('Something went wrong ', err)
  })
  • Create instances of unpacker if needed
import {Unpacker} from 'tarball-unpacker'

// Create a new instance of Unpacker
const unpacker = new Unpacker()

unpacker
  .extractFromURL('http://www.arkaitzgarro.com/tarball.tgz', '/tmp/destination')
  .then(() => {
    console.log('Done!')
  })
  .catch((err) => {
    console.log('Something went wrong ', err)
  })

Options

Available options for configure method:

  • silent (boolean): don't output any log message. Default is true.

Command line

It's also possible to use unpacker as a command line utility, you just need to install it globally with npm install -g tarball-unpacker. Here is the help command output.

Usage: unpacker (<source path> | <url>) <destination folder>

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]

Examples:
  unpacker /tmp/tarball.tgz /tmp/unpacked
  unpacker http://www.arkaitzgarro.com/tarball.tgz /tmp/unpacked
1.2.0

8 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago