Skip to content

Commit

Permalink
Move from optimist to yargs for the benchmark runner
Browse files Browse the repository at this point in the history
Since Mocha uses yargs anyway this isn't a significant increase in total dev dependencies
  • Loading branch information
domenic committed May 23, 2021
1 parent 4a388c7 commit dedb857
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
31 changes: 16 additions & 15 deletions benchmark/runner.js
Expand Up @@ -8,22 +8,23 @@ const benchmarks = require(".");
const fs = require("fs");
const path = require("path");
const { toFileUrl } = require("../lib/jsdom/utils");
const yargs = require("yargs/yargs");
const { hideBin } = require("yargs/helpers");

const optimist = require("optimist")
const { argv } = yargs(hideBin(process.argv))
.usage("Run the jsdom benchmark suite")
.alias("s", "suites")
.string("s")
.describe("s", "suites that you want to run. ie: -s dom/construction/createElement,dom/foo")
.describe("bundle", "generate the JavaScript bundle required to run benchmarks in a browser")
.alias("h", "help")
.describe("h", "show the help");
.option("suites", {
type: "array",
alias: "s",
describe: "suites that you want to run, e.g.: dom/construction/createElement dom/foo"
})
.option("bundle", {
type: "boolean",
describe: "generate the JavaScript bundle required to run benchmarks in a browser"
})
.help();

if (optimist.argv.help) {
optimist.showHelp();
return;
}

if (optimist.argv.bundle) {
if (argv.bundle) {
const bundle = require("browserify")({ debug: true });
bundle.require(path.resolve(__dirname, ".."), { expose: "jsdom" });
bundle.require(path.resolve(__dirname, "browser-runner.js"), { expose: "jsdom-browser-runner" });
Expand All @@ -40,8 +41,8 @@ if (optimist.argv.bundle) {
}

let suitesToRun;
if (optimist.argv.suites) {
suitesToRun = pathToSuites(benchmarks, optimist.argv.suites.trim().split(/,/));
if (argv.suites) {
suitesToRun = pathToSuites(benchmarks, argv.suites);
} else {
suitesToRun = pathToSuites(benchmarks);
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -76,12 +76,12 @@
"minimatch": "^3.0.4",
"mocha": "^8.4.0",
"mocha-sugar-free": "^1.4.0",
"optimist": "0.6.1",
"rimraf": "^3.0.2",
"server-destroy": "^1.0.1",
"watchify": "^4.0.0",
"wd": "^1.14.0",
"webidl2js": "^16.2.0"
"webidl2js": "^16.2.0",
"yargs": "^17.0.1"
},
"browser": {
"canvas": false,
Expand Down Expand Up @@ -111,6 +111,6 @@
},
"main": "./lib/api.js",
"engines": {
"node": ">=10"
"node": ">=12"
}
}
31 changes: 13 additions & 18 deletions yarn.lock
Expand Up @@ -2339,11 +2339,6 @@ minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.3, minimist@^1.2.5:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==

minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=

mkdirp-classic@^0.5.2:
version "0.5.3"
resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113"
Expand Down Expand Up @@ -2504,14 +2499,6 @@ once@^1.3.0, once@^1.4.0:
dependencies:
wrappy "1"

optimist@0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
integrity sha1-2j6nRob6IaGaERwybpDrFaAZZoY=
dependencies:
minimist "~0.0.1"
wordwrap "~0.0.2"

optionator@^0.8.1:
version "0.8.3"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"
Expand Down Expand Up @@ -3626,11 +3613,6 @@ word-wrap@^1.2.3, word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==

wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc=

workerpool@6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.1.0.tgz#a8e038b4c94569596852de7a8ea4228eefdeb37b"
Expand Down Expand Up @@ -3708,6 +3690,19 @@ yargs@16.2.0, yargs@^16.1.1:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.0.1:
version "17.0.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.0.1.tgz#6a1ced4ed5ee0b388010ba9fd67af83b9362e0bb"
integrity sha512-xBBulfCc8Y6gLFcrPvtqKz9hz8SO0l1Ni8GgDekvBX2ro0HRQImDGnikfc33cgzcYUSncapnNcZDjVFIH3f6KQ==
dependencies:
cliui "^7.0.2"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.0"
y18n "^5.0.5"
yargs-parser "^20.2.2"

yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
Expand Down

0 comments on commit dedb857

Please sign in to comment.