@@ -31,7 +31,16 @@ export type OnZipEntryFunction = (entry: Archiver.EntryData) => void;
3131 * ZipOptions is used as input to the zip function.
3232 */
3333export type ZipOptions = {
34- onZipEntry ?: OnZipEntryFunction ;
34+ /**
35+ * onZipAddEntry is called when an entry is added to the archive.
36+ */
37+ onZipAddEntry ?: OnZipEntryFunction ;
38+
39+ /**
40+ * onZipIgnoreEntry is called when an entry is ignored due to an ignore
41+ * specification.
42+ */
43+ onZipIgnoreEntry ?: OnZipEntryFunction ;
3544} ;
3645
3746/**
@@ -60,7 +69,11 @@ export async function zipDir(
6069 const ignores = await parseGcloudIgnore ( ignoreFile ) ;
6170 const ignorer = ignore ( ) . add ( ignores ) ;
6271 const ignoreFn = ( entry : Archiver . EntryData ) : false | Archiver . EntryData => {
63- return ignorer . ignores ( entry . name ) ? false : entry ;
72+ if ( ignorer . ignores ( entry . name ) ) {
73+ if ( opts ?. onZipIgnoreEntry ) opts . onZipIgnoreEntry ( entry ) ;
74+ return false ;
75+ }
76+ return entry ;
6477 } ;
6578
6679 return new Promise ( ( resolve , reject ) => {
@@ -70,7 +83,7 @@ export async function zipDir(
7083 // For some reason, TypeScript complains if this guard is outside the
7184 // closure. It would be more performant just not create this listener, but
7285 // alas...
73- if ( opts ?. onZipEntry ) opts . onZipEntry ( entry ) ;
86+ if ( opts ?. onZipAddEntry ) opts . onZipAddEntry ( entry ) ;
7487 } ) ;
7588 archive . on ( 'warning' , ( err ) => reject ( err ) ) ;
7689 archive . on ( 'error' , ( err ) => reject ( err ) ) ;
0 commit comments