Skip to content

Commit

Permalink
Merge pull request #13 from HyperPlay-Gaming/improve_zipping_logging
Browse files Browse the repository at this point in the history
add zip progress logging
  • Loading branch information
BrettCleary authored Mar 15, 2024
2 parents c01fc15 + 0cc117c commit 871c3cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperplay/cli",
"version": "2.10.2",
"version": "2.10.3",
"description": "Hyperplay CLI",
"author": "HyperPlay Labs, Inc.",
"bin": {
Expand Down
8 changes: 8 additions & 0 deletions src/zip.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';
import archiver from 'archiver';
import { CliUx } from '@oclif/core';

export function zipDirectory(sourceDir: string, outPath: string): Promise<void> {
return new Promise((resolve, reject) => {
Expand All @@ -8,6 +9,12 @@ export function zipDirectory(sourceDir: string, outPath: string): Promise<void>
zlib: { level: 9 }
});

archive.on('progress', (progress)=>{
let progressString = `Zip Progress: Entries ${progress.entries.processed} out of ${progress.entries.total}.`;
progressString += ` Bytes ${progress.fs.processedBytes} out of ${progress.fs.totalBytes}`;
CliUx.ux.log(progressString);
});

output.on('close', function () {
console.log(`Archive created successfully. Total bytes: ${archive.pointer()}`);
resolve();
Expand All @@ -24,6 +31,7 @@ export function zipDirectory(sourceDir: string, outPath: string): Promise<void>

// Catch errors explicitly.
archive.on('error', function (err) {
CliUx.ux.error(err);
reject(err);
});
archive.pipe(output);
Expand Down

0 comments on commit 871c3cb

Please sign in to comment.