SlimIO archive (for addons and modules) tarball packer/extractor.
- Node.js v12 or higher
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/tarballconst { 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);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 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.
| Name | Refactoring | Security Risk | Usage |
|---|---|---|---|
| tar-fs | Minor | High | Pack and extract .tar archive |
| @lukeed/uuid | Minor | Low | Generate unique id for temporary filename |
MIT