Skip to content

Commit

Permalink
Merge branch 'main' into edgedriver
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Dec 30, 2024
2 parents 158ead3 + 708e36d commit a599ed9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 37 deletions.
19 changes: 15 additions & 4 deletions lib/support/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { hideBin } from 'yargs/helpers';
import { findUpSync } from 'find-up';
import get from 'lodash.get';
import set from 'lodash.set';
import hasbin from 'hasbin';
import {
framerate,
crf,
Expand All @@ -16,6 +15,8 @@ import {
import { screenshotDefaults } from '../screenshot/defaults.js';
import { geckoProfilerDefaults } from '../firefox/settings/geckoProfilerDefaults.js';

import { execaSync } from 'execa';

const configPath = findUpSync(['.browsertime.json']);

let config;
Expand All @@ -33,6 +34,16 @@ try {
throw error;
}

function hasbin(bin) {
try {
const cmd = process.platform === 'win32' ? 'where' : 'which';
execaSync(cmd, bin);
return true;
} catch {
return false;
}
}

function validateInput(argv) {
// Check NodeJS major version
const fullVersion = process.versions.node;
Expand Down Expand Up @@ -70,7 +81,7 @@ function validateInput(argv) {
}
}

if ((argv.video || argv.visualMetrics) && !hasbin.sync(['ffmpeg'])) {
if ((argv.video || argv.visualMetrics) && !hasbin(['ffmpeg'])) {
return 'You need to have ffmpeg in your path to be able to record a video.';
}

Expand All @@ -90,11 +101,11 @@ function validateInput(argv) {
return 'There is no benefit running debug mode inside a Docker container.';
}

if (argv.tcpdump && !hasbin.sync(['tcpdump'])) {
if (argv.tcpdump && !hasbin(['tcpdump'])) {
return 'You need to have tcpdump in your path to be able to record a tcpdump.';
}

if (argv.gnirehtet && !hasbin.sync(['gnirehtet'])) {
if (argv.gnirehtet && !hasbin(['gnirehtet'])) {
return 'You need to have gnirehtet in your path to be able to use it. If you run on a Mac you can install it using Homebrew: brew install gnirehtet';
}

Expand Down
32 changes: 0 additions & 32 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"ff-test-bidi-har-export": "0.0.17",
"find-up": "7.0.0",
"get-port": "7.1.0",
"hasbin": "1.2.3",
"intel": "1.2.0",
"lodash.get": "4.4.2",
"lodash.groupby": "4.6.0",
Expand Down

0 comments on commit a599ed9

Please sign in to comment.