0.1.0 • Published 5 years ago

@slimio/tarball v0.1.0

Weekly downloads
16
License
MIT
Repository
github
Last release
5 years ago

Tarball

version Maintenance MIT

SlimIO archive (for addons and modules) tarball packer/extractor.

Requirements

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/tarball
# or
$ yarn add @slimio/tarball

Usage example

const { pack, extract } = require("@slimio/tarball");
const { resolve } = require("path");

async function main() {
    const archiveName = resolve("myArchive.tar");

    // Create .tar archive
    await pack(resolve("directory"), archiveName);

    // Extract .tar to the given directory
    await extract(archiveName, resolve("directoryBis"), {
        deleteTar: true
    });
}
main().catch(console.error);

API

pack(location: string, destination: string, options?: PackOptions): Promise< void >

Pack a location (that must be a directory) into a tar archive.

Options is described by the following interface:

interface PackOptions {
    include?: Set<string>;
}

Example that include only index.js & slimio.toml:

await pack("./myAddon", "myAddon.tar", {
    include: new Set(["index.js", "slimio.toml"])
});

extract(location: string, destination: string, options?: ExtractOptions): Promise< void >

Extract a tar archive to a given destination.

Options is described by the following interface:

interface ExtractOptions {
    deleteTar?: boolean;
    deleteDestinationOnFail?: boolean;
}

By default deleteTar and deleteDestinationOnFail are equal to false.

Dependencies

NameRefactoringSecurity RiskUsage
premoveMinorLowRecursive unlink/rmdir
tar-fsMinorHighPack and extract .tar archive
uuidMinorLowGenerate unique id for temporary filename

License

MIT