Tarball
SlimIO archive (for addons and modules) tarball packer/extractor.
Requirements
- Node.js v10 or higher
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
Name | Refactoring | Security Risk | Usage |
---|---|---|---|
premove | Minor | Low | Recursive unlink/rmdir |
tar-fs | Minor | High | Pack and extract .tar archive |
uuid | Minor | Low | Generate unique id for temporary filename |
License
MIT