Skip to content

Commit fab6f02

Browse files
authored
fix: add debug logging when files are ignored (#348)
1 parent d044b1f commit fab6f02

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,12 @@ async function run(): Promise<void> {
243243
onZip: (sourceDir: string, zipPath: string) => {
244244
logInfo(`Created zip file from '${sourceDir}' at '${zipPath}'`);
245245
},
246-
onZipEntry: (entry: EntryData) => {
246+
onZipAddEntry: (entry: EntryData) => {
247247
logDebug(formatEntry(entry));
248248
},
249+
onZipIgnoreEntry: (entry: EntryData) => {
250+
logDebug(`Ignoring ${entry.name}`);
251+
},
249252
onNew: () => {
250253
logInfo('Creating new Cloud Function deployment');
251254
},

src/util.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ export type OnZipEntryFunction = (entry: Archiver.EntryData) => void;
3131
* ZipOptions is used as input to the zip function.
3232
*/
3333
export 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

Comments
 (0)