Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.swp
dist
node_modules
.DS_Store
.vscode
10 changes: 5 additions & 5 deletions src/utils/unzip.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Readable } from 'stream';
import { promisify } from 'util';
import { Entry, Options, ZipFile } from 'yauzl';
import { Entry, Options, ZipFile, ZipFileOptions } from 'yauzl';

// Override so promisify typing correctly infers params
export type YauzlOpenReadStream = (entry: Entry, callback?: (err: Error, stream: Readable) => void) => Promise<Readable>;
type YauzlOpen = (path: string, options: Options, callback?: (err: Error, zipfile: ZipFile) => void) => void;
type UnzipOnEntry = (entry: Entry, zipfile: ZipFile, openReadStream: YauzlOpenReadStream) => void;
// Specify which of possible overloads is being promisified
type YauzlOpenReadStream = (entry: Entry, options?: ZipFileOptions, callback?: (err: Error, stream: Readable) => void) => void;
type YauzlOpen = (path: string, options?: Options, callback?: (err: Error, zipfile: ZipFile) => void) => void;
type UnzipOnEntry = (entry: Entry, zipfile: ZipFile, openReadStream: (arg1: Entry, arg2?: ZipFileOptions) => Promise<Readable>) => void;

export async function unzip(srcPath: string, onEntry: UnzipOnEntry) {
const yauzl = await import('yauzl');
Expand Down