diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-02-10 20:03:46 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-02-10 22:35:35 +0100 |
commit | 4671d551cf9210434bdadf65ee5654606d24da70 (patch) | |
tree | 5ae6f7f090bcb0e9e58d2753a6af04de8574e717 /benchmark/_cli.js | |
parent | aa0a01bd36101ab087f81a7e8caeca9d3ccc9beb (diff) | |
download | node-new-4671d551cf9210434bdadf65ee5654606d24da70.tar.gz |
Revert "benchmark: add `test` and `all` options and improve errors"
This reverts commit dac579516ca662e731ac502c15e75009a2b9a8c9.
Refs: https://github.com/nodejs/node/pull/31396
PR-URL: https://github.com/nodejs/node/pull/31722
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'benchmark/_cli.js')
-rw-r--r-- | benchmark/_cli.js | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/benchmark/_cli.js b/benchmark/_cli.js index eb6c4add97..771cc72bff 100644 --- a/benchmark/_cli.js +++ b/benchmark/_cli.js @@ -6,16 +6,15 @@ const path = require('path'); // Create an object of all benchmark scripts const benchmarks = {}; fs.readdirSync(__dirname) - .filter((name) => { - return name !== 'fixtures' && - fs.statSync(path.resolve(__dirname, name)).isDirectory(); - }) + .filter((name) => fs.statSync(path.resolve(__dirname, name)).isDirectory()) .forEach((category) => { benchmarks[category] = fs.readdirSync(path.resolve(__dirname, category)) .filter((filename) => filename[0] !== '.' && filename[0] !== '_'); }); function CLI(usage, settings) { + if (!(this instanceof CLI)) return new CLI(usage, settings); + if (process.argv.length < 3) { this.abort(usage); // Abort will exit the process } @@ -23,7 +22,6 @@ function CLI(usage, settings) { this.usage = usage; this.optional = {}; this.items = []; - this.test = false; for (const argName of settings.arrayArgs) { this.optional[argName] = []; @@ -36,7 +34,7 @@ function CLI(usage, settings) { if (arg === '--') { // Only items can follow -- mode = 'item'; - } else if (mode === 'both' && arg[0] === '-') { + } else if ('both' === mode && arg[0] === '-') { // Optional arguments declaration if (arg[1] === '-') { @@ -63,8 +61,6 @@ function CLI(usage, settings) { // The next value can be either an option or an item mode = 'both'; - } else if (arg === 'test') { - this.test = true; } else if (['both', 'item'].includes(mode)) { // item arguments this.items.push(arg); @@ -87,15 +83,9 @@ CLI.prototype.abort = function(msg) { CLI.prototype.benchmarks = function() { const paths = []; - if (this.items.includes('all')) { - this.items = Object.keys(benchmarks); - } - for (const category of this.items) { - if (benchmarks[category] === undefined) { - console.error(`The "${category}" category does not exist.`); - process.exit(1); - } + if (benchmarks[category] === undefined) + continue; for (const scripts of benchmarks[category]) { if (this.shouldSkip(scripts)) continue; |