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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Options:
--html Generate HTML report (default: false)
--openHtml Open HTML report in browser (requires --html) (default: false)
--list Generate a list of test results as HTML (default: false)
--zip Zip the results of the test into the results directory. (default: false)
--help display help for command
```

Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { DEFAULT_OPTIONS } from './lib/defaultOptions.js';
* @property {boolean=} html
* @property {boolean=} openHtml
* @property {boolean=} list
* @property {boolean=} zip
*/

/**
Expand Down Expand Up @@ -260,6 +261,12 @@ export default function browserAgent() {
DEFAULT_OPTIONS.list,
),
)
.addOption(
new Option(
'--zip',
'Zip the results of the test into the results directory.',
).default(DEFAULT_OPTIONS.zip),
)
.parse(process.argv);

const cliOptions = program.opts();
Expand Down
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function normalizeCLIConfig(options) {
list: options.list || DEFAULT_OPTIONS.list,
connectionType: options.connectionType || DEFAULT_OPTIONS.connectionType,
auth: options.auth || DEFAULT_OPTIONS.auth,
zip: options.zip || DEFAULT_OPTIONS.zip,
};

// Parse JSON strings from CLI (pass through objects from programmatic)
Expand Down
2 changes: 2 additions & 0 deletions lib/defaultOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ export const DEFAULT_OPTIONS = {
connectionType: false,
// HTTP basic auth credentials (false = no auth)
auth: false,
// Compress output to zip file (false = no zip)
zip: false,
};
13 changes: 13 additions & 0 deletions lib/testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { networkTypes } from './connectivity.js';
import ffmpeg from 'ffmpeg';
import ejs from 'ejs';
import { log, logTimer, generateTestID } from './helpers.js';
import AdmZip from 'adm-zip';

class TestRunner {
args = [];
Expand Down Expand Up @@ -531,6 +532,18 @@ class TestRunner {
}
}

// handle the zipping
if (this.options.zip) {
try {
const outputZip = `./results/${this.TESTID}.zip`;
const zip = new AdmZip();
zip.addLocalFolder(this.paths['results']);
zip.writeZip(outputZip);
} catch (err) {
console.error('Error creating zip file:', err);
}
}

//run cleanup
this.cleanup();
}
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"dependencies": {
"@sitespeed.io/throttle": "^5.0.0",
"adm-zip": "^0.5.16",
"commander": "^10.0.0",
"ejs": "^3.1.10",
"ffmpeg": "^0.0.4",
Expand Down