Skip to content

Commit

Permalink
Bump Version to 1.1.0
Browse files Browse the repository at this point in the history
- adding support for customWriteStreams
- updating all used libraries to the latest version
  • Loading branch information
maugenst committed Jul 7, 2021
1 parent 657b1b9 commit 58ad442
Show file tree
Hide file tree
Showing 12 changed files with 9,161 additions and 4,391 deletions.
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@

# zip-a-folder
Easy to use zip (or tar) a complete folder plain into a zip file
including compression ratio handling.

Version 1.0+ is incompatible to elder versions since it introduces a
breaking API change.
* Callback function is NOT supported anymore.
* Provide the possibility to create tar archives.
* Set compression ratio (three levels supported by now uncompressed, medium and high)
including compression ratio handling and custom write streams.

## Basic Usage

Expand Down Expand Up @@ -62,7 +56,30 @@ import { zip, COMPRESSION_LEVEL } from 'zip-a-folder';
class TestMe {

static async main() {
await zip('/path/to/the/folder', '/path/to/archive.zip', COMPRESSION_LEVEL.high);
await zip('/path/to/the/folder', '/path/to/archive.zip', {compression: COMPRESSION_LEVEL.high});
}
}

TestMe.main();
```
### Custom writeStreams
You can now pipe output to any WriteStream (just pass WriteStream as a parameter).

To keep the existing api stable the 2nd parameter (targetFilePath) can now be either undefined or
an empty string.

ATTENTION: customWritestreams cannot be checked. So it is up to the user to check
on non existing target folders or if the targetfolder equals to the sourcefolder
(which leads to a circularity).

```js
import { zip, COMPRESSION_LEVEL } from 'zip-a-folder';
import { fs } from 'fs';

class TestMe {
static async main() {
const customWS = fs.createWriteStream('test/1234.zip');
await zipafolder.zip(path.resolve(__dirname, 'data/'), undefined, {customWriteStream: customWS});
}
}

Expand Down
10 changes: 8 additions & 2 deletions dist/lib/ZipAFolder.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
/// <reference types="node" />
import { WriteStream } from 'fs';
export declare enum COMPRESSION_LEVEL {
uncompressed = 0,
medium = 5,
high = 9
}
export declare type ZipAFolderOptions = {
compression?: COMPRESSION_LEVEL;
customWriteStream?: WriteStream;
};
export declare class ZipAFolder {
static tar(srcFolder: string, zipFilePath: string, compression?: COMPRESSION_LEVEL): Promise<void | Error>;
static zip(srcFolder: string, zipFilePath: string, compression?: COMPRESSION_LEVEL): Promise<void | Error>;
static tar(srcFolder: string, tarFilePath: string | undefined, zipAFolderOptions?: ZipAFolderOptions): Promise<void | Error>;
static zip(srcFolder: string, zipFilePath: string | undefined, zipAFolderOptions?: ZipAFolderOptions): Promise<void | Error>;
private static compress;
}
export declare const zip: typeof ZipAFolder.zip;
Expand Down
84 changes: 62 additions & 22 deletions dist/lib/ZipAFolder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lib/ZipAFolder.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 30 additions & 6 deletions dist/test/tests-ZipAFolder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 58ad442

Please sign in to comment.