From e08d1868f5237cdbc76069d2c34a0803230bb63b Mon Sep 17 00:00:00 2001 From: Trevor D McKeown Date: Sat, 20 Jan 2024 17:15:47 -0500 Subject: [PATCH 1/3] Print Derived Configuration Report (#517) feat: print derived config variables feat: print derived config variables in json test: 12 new unit tests to support features test: 1 skipped unit test for discovered bug in yargs with reports param --- c8-ascii-art.txt | 9 + lib/parse-args.js | 152 ++++- package-lock.json | 924 +++++++++++++----------------- test/help-message-unix.js.snap | 13 + test/help-message-windows.js.snap | 13 + test/help-message.js | 128 +++++ test/integration.js.snap | 8 +- test/print-config-helpers.js | 75 +++ test/print-config-unix.js.snap | 54 ++ test/print-config-windows.js.snap | 54 ++ test/print-config.js | 144 +++++ 11 files changed, 1028 insertions(+), 546 deletions(-) create mode 100644 c8-ascii-art.txt create mode 100644 test/help-message-unix.js.snap create mode 100644 test/help-message-windows.js.snap create mode 100644 test/help-message.js create mode 100644 test/print-config-helpers.js create mode 100644 test/print-config-unix.js.snap create mode 100644 test/print-config-windows.js.snap create mode 100644 test/print-config.js diff --git a/c8-ascii-art.txt b/c8-ascii-art.txt new file mode 100644 index 00000000..51ce5f4f --- /dev/null +++ b/c8-ascii-art.txt @@ -0,0 +1,9 @@ +/* ________/\\\\\\\\\_ _____/\\\\\\\\\____ */ +/* _____/\\\////////__ ___/\\\///////\\\__ */ +/* ___/\\\/___________ __\/\\\_____\/\\\__ */ +/* __/\\\_____________ __\///\\\\\\\\\/___ */ +/* _\/\\\_____________ ___/\\\///////\\\__ */ +/* _\//\\\____________ __/\\\______\//\\\_ */ +/* __\///\\\__________ _\//\\\______/\\\__ */ +/* ____\////\\\\\\\\\_ __\///\\\\\\\\\/___ */ +/* _______\/////////__ ____\/////////_____ */ \ No newline at end of file diff --git a/lib/parse-args.js b/lib/parse-args.js index 21a9cd7a..7e87d269 100644 --- a/lib/parse-args.js +++ b/lib/parse-args.js @@ -158,8 +158,18 @@ function buildYargs (withCommands = false) { describe: 'supplying --merge-async will merge all v8 coverage reports asynchronously and incrementally. ' + 'This is to avoid OOM issues with Node.js runtime.' }) + .options('print-config', { + default: false, + type: 'boolean', + describe: 'Print the derived configuration between command line parameters and loaded configuration file' + }) + // Todo: refactor. Use parse-args options. + .options('print-config-format', { + default: 'text', + type: 'string', + describe: 'Format to print the configuration in. Accepted formats are either text or json' + }) .pkgConf('c8') - .demandCommand(1) .check((argv) => { if (!argv.tempDirectory) { argv.tempDirectory = resolve(argv.reportsDir, 'tmp') @@ -181,6 +191,38 @@ function buildYargs (withCommands = false) { // } // }) + const argv = process.argv.slice(2) + const checkArgs = parser(argv) + + let shouldPrint = false + + if (Object.keys(checkArgs).includes('print-config')) { + // checkArgs['print-config'] could contain a boolean or a string + // representing a boolean. + if (typeof checkArgs['print-config'] === 'boolean') { + shouldPrint = checkArgs['print-config'] + } else if (typeof checkArgs['print-config'] === 'string') { + shouldPrint = JSON.parse(checkArgs['print-config']) + } + } + + if (shouldPrint) { + const commandExecutedReference = 'c8 ' + argv.join(' ') + const args = yargs.parse(hideInstrumenteeArgs()) + const cleanArgs = cleanUpArgumentArray(args) + + if (args.printConfigFormat === 'text') { + printConfigText(cleanArgs, commandExecutedReference) + } else if (checkArgs.printConfigFormat === 'json') { + const jsonYargs = JSON.stringify(cleanArgs, 2) + console.log(jsonYargs) + } + + process.exit() + } + + yargs.demandCommand(1) + const checkCoverage = require('./commands/check-coverage') const report = require('./commands/report') if (withCommands) { @@ -217,6 +259,114 @@ function hideInstrumenteeArgs () { return argv } +/** Todo: Refactor. Add jsdocs styled comments. Put functions below in their own file */ +// Todo: Take a look at Optimizing this function +// exclude certain temporary values and duplicates from printing +// the same variable will be included twice with different keys +// for example args['temp-directory'] && args['tempDirectory'] +// are essentially the same variable +function cleanUpArgumentArray (args) { + const argsToPrint = {} + Object.keys(args).forEach(v => { + if (v && v.length > 1 && v !== '_' && v !== '$0') { + // See if we are dealing with a Camel Case key string + const matches = [...v.matchAll(/([A-Z])/g)] + if (matches.length > 0) { + matches.forEach(m => { + // Derive Kebab Case string from Camel Case Key string + const newKey = m.input.replace(/([A-Z])/g, '-$1').toLowerCase() + // If the Kebab Case key is not assigned a value + if (!args[newKey]) { + // Then assigned it the Camel Case Variable + argsToPrint[newKey] = args[v] + } else if (!args[v]) { + // Other wise assign keep the Kebab Case key value + argsToPrint[newKey] = args[newKey] + } + }) + } else { + // Just keep the value. Either Kebab case or otherwise + argsToPrint[v] = args[v] + } + } + }) + + return argsToPrint +} + +function printConfigText (argsv, commandExecutedReference) { + /** + * Todo: Refactor: Put this line in a string literal + * + */ + const banner = readFileSync('./c8-ascii-art.txt', 'utf-8') + console.log('\n\n') + console.log(banner) + console.log('\n\n') + console.log('Command Issued: ' + commandExecutedReference) + console.log('Config File Loaded: ' + argsv.config + '\n\n\n') + console.log('Derived Configuration from CLI options and configuration file') + console.log('------------------------------------------------------------------------------') + /* End refactor note */ + + const addSpace = (numOfSpace) => { + let space = '' + for (let i = 0; i < numOfSpace; i++) space += ' ' + const s = space + return s + } + + /** Todo: Refactor: + * Put in a console.table format. + * + */ + // Including some formatting variables + // for spacing to make the output more readable + let output = '' + let spaceLength = Object.keys(argsv) + .map(v => String(v).length) + .reduce((p, c) => { + return (p >= c) ? p : c + }) + spaceLength += 10 + + // For each configuration value, print pretty + Object.keys(argsv).forEach(v => { + const fillSpace = addSpace(spaceLength - v.length) + const enumSpace = addSpace(spaceLength) + const value = formatPrintVariable(argsv[v], enumSpace) + output += String(v) + ':' + fillSpace + value + '\n' + }) + /** End Refactor */ + console.log(output) +} + +function formatPrintVariable (variable, space) { + let value + + if (Array.isArray(variable) && variable.length > 0) { + value = stringifyObject(variable, space, ']') + } else if (typeof variable === 'object' && Object.keys(variable).length > 0) { + value = stringifyObject(variable, space, '}') + } else if (typeof variable === 'string' && variable) { + value = "'" + variable + "'" + } else if (typeof variable === 'string' && !variable) { + value = "''" + } else { + value = variable + } + + return value +} + +function stringifyObject (variable, space, closingChar) { + const closeReg = new RegExp('\n' + closingChar, 'g') + const out = JSON.stringify(variable, null, '\t\t\t\t ') + .replace(closeReg, '\n' + space + ' ' + closingChar) + + return out +} + module.exports = { buildYargs, hideInstrumenterArgs, diff --git a/package-lock.json b/package-lock.json index 2c60c943..375d7523 100644 --- a/package-lock.json +++ b/package-lock.json @@ -100,6 +100,16 @@ "node": ">=12" } }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@eslint/eslintrc": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.3.0.tgz", @@ -143,18 +153,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/@eslint/eslintrc/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/@istanbuljs/schema": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", @@ -177,13 +175,12 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, + "version": "0.3.21", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz", + "integrity": "sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==", "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, "node_modules/@tsconfig/node10": { @@ -222,9 +219,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.10.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz", - "integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==", + "version": "20.11.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.5.tgz", + "integrity": "sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -258,9 +255,9 @@ } }, "node_modules/acorn-walk": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.1.tgz", - "integrity": "sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw==", + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", "dev": true, "engines": { "node": ">=0.4.0" @@ -292,24 +289,25 @@ } }, "node_modules/ansi-regex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", - "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true, + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dependencies": { - "color-convert": "^1.9.0" + "color-convert": "^2.0.1" }, "engines": { - "node": ">=4" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/anymatch": { @@ -533,9 +531,9 @@ } }, "node_modules/chai": { - "version": "4.3.10", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", - "integrity": "sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", + "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==", "dev": true, "dependencies": { "assertion-error": "^1.1.0", @@ -577,6 +575,33 @@ "node": ">=4" } }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/chalk/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, "node_modules/chalk/node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -651,19 +676,20 @@ } }, "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dependencies": { - "color-name": "1.1.3" + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" } }, "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "node_modules/concat-map": { "version": "0.0.1", @@ -1198,18 +1224,6 @@ "node": ">=4" } }, - "node_modules/eslint-plugin-import/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/eslint-plugin-import/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -1278,18 +1292,6 @@ "node": ">= 4" } }, - "node_modules/eslint-plugin-node/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/eslint-plugin-node/node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -1350,16 +1352,13 @@ "node": ">=0.10.0" } }, - "node_modules/eslint-plugin-react/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "node_modules/eslint-plugin-react/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, "engines": { - "node": "*" + "node": ">=4.0" } }, "node_modules/eslint-plugin-react/node_modules/resolve": { @@ -1392,15 +1391,6 @@ "node": ">=8.0.0" } }, - "node_modules/eslint-scope/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/eslint-utils": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", @@ -1434,21 +1424,6 @@ "node": ">=10" } }, - "node_modules/eslint/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/eslint/node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -1474,24 +1449,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/eslint/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/eslint/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "node_modules/eslint/node_modules/js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", @@ -1505,18 +1462,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/eslint/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/espree": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", @@ -1565,6 +1510,15 @@ "node": ">=0.10" } }, + "node_modules/esquery/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", @@ -1577,7 +1531,7 @@ "node": ">=4.0" } }, - "node_modules/estraverse": { + "node_modules/esrecurse/node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", @@ -1586,6 +1540,15 @@ "node": ">=4.0" } }, + "node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -1827,14 +1790,14 @@ } }, "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, @@ -1857,17 +1820,6 @@ "node": ">= 6" } }, - "node_modules/glob/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/globals": { "version": "12.4.0", "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", @@ -2607,21 +2559,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/log-symbols/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/log-symbols/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -2638,24 +2575,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/log-symbols/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/log-symbols/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -2709,15 +2628,14 @@ "dev": true }, "node_modules/minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", - "dev": true, + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dependencies": { "brace-expansion": "^1.1.7" }, "engines": { - "node": ">=10" + "node": "*" } }, "node_modules/minimist": { @@ -2816,6 +2734,50 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/mocha/node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", + "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/mocha/node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -3383,6 +3345,42 @@ "ansi-styles": "^3.2.0" } }, + "node_modules/pretty-format/node_modules/ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pretty-format/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/pretty-format/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -3612,13 +3610,13 @@ } }, "node_modules/safe-array-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.1.tgz", - "integrity": "sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.0.tgz", + "integrity": "sha512-ZdQ0Jeb9Ofti4hbt5lX3T2JcAamT9hfzYU1MNB+z/jaEbB6wfFfPIR/zEORmZqobkCCJhSjodobH6WHNmJ97dg==", "dev": true, "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.2.1", + "call-bind": "^1.0.5", + "get-intrinsic": "^1.2.2", "has-symbols": "^1.0.3", "isarray": "^2.0.5" }, @@ -3650,15 +3648,18 @@ ] }, "node_modules/safe-regex-test": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", - "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.2.tgz", + "integrity": "sha512-83S9w6eFq12BBIJYvjMux6/dkirb8+4zJRA9cxNBVb7Wq5fJBW+Xze48WqR8pxua7bDuAaaAxtVVd4Idjp1dBQ==", "dev": true, "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.3", + "call-bind": "^1.0.5", + "get-intrinsic": "^1.2.2", "is-regex": "^1.1.4" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -3687,15 +3688,16 @@ } }, "node_modules/set-function-length": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", - "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", + "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", "dev": true, "dependencies": { "define-data-property": "^1.1.1", - "get-intrinsic": "^1.2.1", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.2", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "has-property-descriptors": "^1.0.1" }, "engines": { "node": ">= 0.4" @@ -3776,39 +3778,6 @@ "url": "https://github.com/chalk/slice-ansi?sponsor=1" } }, - "node_modules/slice-ansi/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/slice-ansi/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/slice-ansi/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "node_modules/spdx-correct": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", @@ -4001,14 +3970,6 @@ "node": ">=8" } }, - "node_modules/strip-ansi/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "engines": { - "node": ">=8" - } - }, "node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", @@ -4104,17 +4065,6 @@ "node": ">=8" } }, - "node_modules/test-exclude/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -4372,15 +4322,6 @@ "node": ">=10.12.0" } }, - "node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.20", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", - "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -4458,40 +4399,10 @@ "engines": { "node": ">=10" }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -4626,6 +4537,18 @@ "dev": true, "requires": { "@jridgewell/trace-mapping": "0.3.9" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + } } }, "@eslint/eslintrc": { @@ -4664,15 +4587,6 @@ "argparse": "^1.0.7", "esprima": "^4.0.0" } - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } } } }, @@ -4692,13 +4606,12 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, + "version": "0.3.21", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz", + "integrity": "sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==", "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, "@tsconfig/node10": { @@ -4737,9 +4650,9 @@ "dev": true }, "@types/node": { - "version": "20.10.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz", - "integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==", + "version": "20.11.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.5.tgz", + "integrity": "sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==", "dev": true, "requires": { "undici-types": "~5.26.4" @@ -4765,9 +4678,9 @@ "requires": {} }, "acorn-walk": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.1.tgz", - "integrity": "sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw==", + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", "dev": true }, "ajv": { @@ -4789,18 +4702,16 @@ "dev": true }, "ansi-regex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", - "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" }, "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "requires": { - "color-convert": "^1.9.0" + "color-convert": "^2.0.1" } }, "anymatch": { @@ -4964,9 +4875,9 @@ "dev": true }, "chai": { - "version": "4.3.10", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", - "integrity": "sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", + "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==", "dev": true, "requires": { "assertion-error": "^1.1.0", @@ -4999,6 +4910,30 @@ "supports-color": "^5.3.0" }, "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -5052,19 +4987,17 @@ } }, "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "requires": { - "color-name": "1.1.3" + "color-name": "~1.1.4" } }, "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "concat-map": { "version": "0.0.1", @@ -5334,15 +5267,6 @@ "v8-compile-cache": "^2.0.3" }, "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -5362,21 +5286,6 @@ "supports-color": "^7.1.0" } }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", @@ -5386,15 +5295,6 @@ "argparse": "^1.0.7", "esprima": "^4.0.0" } - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } } } }, @@ -5524,15 +5424,6 @@ "path-exists": "^3.0.0" } }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -5585,15 +5476,6 @@ "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", "dev": true }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, "semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -5639,14 +5521,11 @@ "esutils": "^2.0.2" } }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true }, "resolve": { "version": "2.0.0-next.5", @@ -5669,14 +5548,6 @@ "requires": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" - }, - "dependencies": { - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - } } }, "eslint-utils": { @@ -5734,6 +5605,14 @@ "dev": true, "requires": { "estraverse": "^5.1.0" + }, + "dependencies": { + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + } } }, "esrecurse": { @@ -5743,12 +5622,20 @@ "dev": true, "requires": { "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + } } }, "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, "esutils": { @@ -5925,26 +5812,16 @@ } }, "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" - }, - "dependencies": { - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "requires": { - "brace-expansion": "^1.1.7" - } - } } }, "glob-parent": { @@ -6497,15 +6374,6 @@ "is-unicode-supported": "^0.1.0" }, "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -6515,21 +6383,6 @@ "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true } } }, @@ -6574,10 +6427,9 @@ "dev": true }, "minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", - "dev": true, + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "requires": { "brace-expansion": "^1.1.7" } @@ -6652,6 +6504,40 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "minimatch": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", + "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, "supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -7066,6 +6952,38 @@ "requires": { "ansi-regex": "^3.0.0", "ansi-styles": "^3.2.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + } } }, "progress": { @@ -7236,13 +7154,13 @@ } }, "safe-array-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.1.tgz", - "integrity": "sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.0.tgz", + "integrity": "sha512-ZdQ0Jeb9Ofti4hbt5lX3T2JcAamT9hfzYU1MNB+z/jaEbB6wfFfPIR/zEORmZqobkCCJhSjodobH6WHNmJ97dg==", "dev": true, "requires": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.2.1", + "call-bind": "^1.0.5", + "get-intrinsic": "^1.2.2", "has-symbols": "^1.0.3", "isarray": "^2.0.5" } @@ -7254,13 +7172,13 @@ "dev": true }, "safe-regex-test": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", - "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.2.tgz", + "integrity": "sha512-83S9w6eFq12BBIJYvjMux6/dkirb8+4zJRA9cxNBVb7Wq5fJBW+Xze48WqR8pxua7bDuAaaAxtVVd4Idjp1dBQ==", "dev": true, "requires": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.3", + "call-bind": "^1.0.5", + "get-intrinsic": "^1.2.2", "is-regex": "^1.1.4" } }, @@ -7282,15 +7200,16 @@ } }, "set-function-length": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", - "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", + "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", "dev": true, "requires": { "define-data-property": "^1.1.1", - "get-intrinsic": "^1.2.1", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.2", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "has-property-descriptors": "^1.0.1" } }, "set-function-name": { @@ -7342,32 +7261,6 @@ "ansi-styles": "^4.0.0", "astral-regex": "^2.0.0", "is-fullwidth-code-point": "^3.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - } } }, "spdx-correct": { @@ -7502,13 +7395,6 @@ "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "requires": { "ansi-regex": "^5.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" - } } }, "strip-bom": { @@ -7578,16 +7464,6 @@ "@istanbuljs/schema": "^0.1.2", "glob": "^7.1.4", "minimatch": "^3.0.4" - }, - "dependencies": { - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "requires": { - "brace-expansion": "^1.1.7" - } - } } }, "text-table": { @@ -7773,17 +7649,6 @@ "@jridgewell/trace-mapping": "^0.3.12", "@types/istanbul-lib-coverage": "^2.0.1", "convert-source-map": "^2.0.0" - }, - "dependencies": { - "@jridgewell/trace-mapping": { - "version": "0.3.20", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", - "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", - "requires": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - } } }, "validate-npm-package-license": { @@ -7844,29 +7709,6 @@ "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - } } }, "wrappy": { diff --git a/test/help-message-unix.js.snap b/test/help-message-unix.js.snap new file mode 100644 index 00000000..33056bbc --- /dev/null +++ b/test/help-message-unix.js.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`--print-config 1`] = `",/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-configConfigFileLoaded:./.nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile------------------------------------------------------------------------------100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'./.nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'./coverage/tmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text',"`; + +exports[`--print-config=false 1`] = `",,c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\"./coverage/tmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereportersNotenoughnon-optionarguments:got0,needatleast1"`; + +exports[`--print-config=false 2`] = `",zeropositivenegative--------------|---------|----------|---------|---------|-------------------File|%Stmts|%Branch|%Funcs|%Lines|UncoveredLine#s--------------|---------|----------|---------|---------|-------------------Allfiles|64.28|66.66|50|64.28|vanilla|78.26|75|100|78.26|loaded.js|73.68|71.42|100|73.68|4-5,16-18main.js|100|100|100|100|vanilla/dir|0|0|0|0|unloaded.js|0|0|0|0|1-5--------------|---------|----------|---------|---------|-------------------,"`; + +exports[`--print-config=true 1`] = `",/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-config=trueConfigFileLoaded:./.nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile------------------------------------------------------------------------------100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'./.nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'./coverage/tmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text',"`; + +exports[`ensure the help message is correct 1`] = `",c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\"./coverage/tmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereporters,"`; + +exports[`ensure warning message 1`] = `",,c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\"./coverage/tmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereportersNotenoughnon-optionarguments:got0,needatleast1"`; diff --git a/test/help-message-windows.js.snap b/test/help-message-windows.js.snap new file mode 100644 index 00000000..48a41fc9 --- /dev/null +++ b/test/help-message-windows.js.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`--print-config 1`] = `",/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-configConfigFileLoaded:..nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile------------------------------------------------------------------------------100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'..nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'.coveragetmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text',"`; + +exports[`--print-config=false 1`] = `",,c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\".coveragetmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereportersNotenoughnon-optionarguments:got0,needatleast1"`; + +exports[`--print-config=false 2`] = `",zeropositivenegative--------------|---------|----------|---------|---------|-------------------File|%Stmts|%Branch|%Funcs|%Lines|UncoveredLine#s--------------|---------|----------|---------|---------|-------------------Allfiles|64.28|66.66|50|64.28|vanilla|78.26|75|100|78.26|loaded.js|73.68|71.42|100|73.68|4-5,16-18main.js|100|100|100|100|vanilla/dir|0|0|0|0|unloaded.js|0|0|0|0|1-5--------------|---------|----------|---------|---------|-------------------,"`; + +exports[`--print-config=true 1`] = `",/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-config=trueConfigFileLoaded:..nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile------------------------------------------------------------------------------100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'..nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'.coveragetmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text',"`; + +exports[`ensure the help message is correct 1`] = `",c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\".coveragetmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereporters,"`; + +exports[`ensure warning message 1`] = `",,c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\".coveragetmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereportersNotenoughnon-optionarguments:got0,needatleast1"`; diff --git a/test/help-message.js b/test/help-message.js new file mode 100644 index 00000000..0f162812 --- /dev/null +++ b/test/help-message.js @@ -0,0 +1,128 @@ +/* global describe, before, beforeEach, it */ + +const { runSpawn } = require('./print-config-helpers') +const c8Path = require.resolve('../bin/c8') +const { rm } = require('fs') +const os = require('os') +const isWin = (os.platform() === 'win32') +const OsStr = (isWin) ? 'windows' : 'unix' +const shouldCompressSnapShot = true +const nodePath = process.execPath + +const chaiJestSnapshot = require('chai-jest-snapshot') +require('chai').should() +require('chai') + .use(chaiJestSnapshot) + .should() + +before(cb => rm('tmp', { recursive: true, force: true }, cb)) + +beforeEach(function () { + chaiJestSnapshot.configureUsingMochaContext(this) +}) + +describe(`Help Message - ${OsStr}`, function () { + // Ensure the help message is correct - Snapshot of help message + /** + * Test: Ensure Help Message is Correct + * Command: c8 --help + * + * Runs the hep option and compares to a snapshot + */ + it('ensure the help message is correct', function () { + chaiJestSnapshot.setTestName('ensure the help message is correct') + chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) + const output = runSpawn([c8Path, '--help'], true, shouldCompressSnapShot) + + output.should.matchSnapshot() + }) + + describe('should demand arguments', function () { + /** + * Test: Ensure 'not enough non-option arguments' warning message + * Command: c8 + * + * Runs c8 with incorrect options to make sure it produces a warning + * + */ + it('ensure warning message', function () { + chaiJestSnapshot.setTestName('ensure warning message') + chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) + const output = runSpawn([c8Path], true, shouldCompressSnapShot) + + output.should.matchSnapshot() + }) + + /** + * + * Test: should demand arguments: --print-config=false + * Command: c8 --print-config=false + * + */ + it('--print-config=false', function () { + chaiJestSnapshot.setTestName('--print-config=false') + chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) + const out = runSpawn([c8Path, '--print-config=false'], true, shouldCompressSnapShot) + out.should.matchSnapshot() + }) + }) + + describe('should not demand arguments', function () { + /** + * + * Test: should not demand any arguments: --print-config=true + * Command: c8 --print-config=true + * + * if print-config is true, c8 shouldn't demand any arguments + * + */ + it('--print-config=true', function () { + chaiJestSnapshot.setTestName('--print-config=true') + chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) + const out = runSpawn([c8Path, '--print-config=true'], true, shouldCompressSnapShot) + out.should.matchSnapshot() + }) + + /** + * + * Test: should not demand any arguments: --print-config + * Command: c8 --print-config + * + * Other variation of if print-config is true, c8 shouldn't + * demand any arguments + * + */ + it('--print-config', function () { + chaiJestSnapshot.setTestName('--print-config') + chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) + const out = runSpawn([c8Path, '--print-config'], true, shouldCompressSnapShot) + out.should.matchSnapshot() + }) + + /** + * + * Test: should not demand arguments: --print-config=false + * Command: c8 --print-config=false --temp-directory=tmp/vanilla-all \ + * --clean=false --all=true --include=test/fixtures/all/vanilla/**\/*.js + * --exclude=**\/*.ts node ./fixtures/all/vanilla/main + * + */ + it('--print-config=false', function () { + chaiJestSnapshot.setTestName('--print-config=false') + chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) + const args = [ + c8Path, + '--print-config=false', + '--temp-directory=tmp/vanilla-all', + '--clean=false', + '--all=true', + '--include=test/fixtures/all/vanilla/**/*.js', + '--exclude=**/*.ts', // add an exclude to avoid default excludes of test/** + nodePath, + require.resolve('./fixtures/all/vanilla/main') + ] + const out = runSpawn(args, true, shouldCompressSnapShot) + out.should.matchSnapshot() + }) + }) +}) diff --git a/test/integration.js.snap b/test/integration.js.snap index a9279c7e..9cfdd3c1 100644 --- a/test/integration.js.snap +++ b/test/integration.js.snap @@ -156,7 +156,7 @@ hey ---------------------------------------|---------|----------|---------|---------|------------------------ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ---------------------------------------|---------|----------|---------|---------|------------------------ -All files | 3.52 | 12.5 | 6.52 | 3.52 | +All files | 3.24 | 12.5 | 6.52 | 3.24 | c8 | 0 | 0 | 0 | 0 | index.js | 0 | 0 | 0 | 0 | 1 c8/bin | 0 | 0 | 0 | 0 | @@ -166,7 +166,7 @@ All files | 3.52 | 12.5 | 6.52 | 3.52 prettify.js | 0 | 0 | 0 | 0 | 1-2 sorter.js | 0 | 0 | 0 | 0 | 1-196 c8/lib | 0 | 0 | 0 | 0 | - parse-args.js | 0 | 0 | 0 | 0 | 1-224 + parse-args.js | 0 | 0 | 0 | 0 | 1-362 report.js | 0 | 0 | 0 | 0 | 1-402 source-map-from-file.js | 0 | 0 | 0 | 0 | 1-100 c8/lib/commands | 0 | 0 | 0 | 0 | @@ -521,7 +521,7 @@ hey ---------------------------------------|---------|----------|---------|---------|------------------------ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ---------------------------------------|---------|----------|---------|---------|------------------------ -All files | 3.52 | 12.5 | 6.52 | 3.52 | +All files | 3.24 | 12.5 | 6.52 | 3.24 | c8 | 0 | 0 | 0 | 0 | index.js | 0 | 0 | 0 | 0 | 1 c8/bin | 0 | 0 | 0 | 0 | @@ -531,7 +531,7 @@ All files | 3.52 | 12.5 | 6.52 | 3.52 prettify.js | 0 | 0 | 0 | 0 | 1-2 sorter.js | 0 | 0 | 0 | 0 | 1-196 c8/lib | 0 | 0 | 0 | 0 | - parse-args.js | 0 | 0 | 0 | 0 | 1-224 + parse-args.js | 0 | 0 | 0 | 0 | 1-362 report.js | 0 | 0 | 0 | 0 | 1-402 source-map-from-file.js | 0 | 0 | 0 | 0 | 1-100 c8/lib/commands | 0 | 0 | 0 | 0 | diff --git a/test/print-config-helpers.js b/test/print-config-helpers.js new file mode 100644 index 00000000..3fe6de5c --- /dev/null +++ b/test/print-config-helpers.js @@ -0,0 +1,75 @@ +const { spawnSync } = require('child_process') +const os = require('os') + +const nodePath = process.execPath +const isWin = (os.platform() === 'win32') +const pwd = process.cwd() +const whiteSpaceReg = /[\\\s]/g +const pwdReg = new RegExp(pwd, 'g') + +const runSpawn = (args, text = false, stripWhiteSpace = false) => { + const doubleQuoteReg = /"/g + const slashReg = /\\/g + + const { output } = spawnSync(nodePath, args) + + let out = output.toString('utf8') + + if (isWin && text) { + const jsonEncodedPwd = JSON.stringify(pwd) + .replace(doubleQuoteReg, '') + const encodedPwdRegEx = new RegExp(jsonEncodedPwd, 'g') + out = out.replace(encodedPwdRegEx, '.') + } else if (isWin && !text) { + const jsonEncodedPwd = JSON.stringify(pwd) + .replace(doubleQuoteReg, '') + .replace(slashReg, '\\\\') + const encodedPwdRegEx = new RegExp(jsonEncodedPwd, 'g') + out = out.replace(encodedPwdRegEx, '.') + } else if (!isWin) { + out = out.replace(pwdReg, '.') + } + + // For certain cases we need to strip out all whitespace in + // snapshots. It's not ideal and it makes it hard to read + // but I am concern about this issue in the chai-snapshot + // package + // + // https://github.com/jestjs/jest/pull/9203 + + if (text && stripWhiteSpace) { out = out.replace(whiteSpaceReg, '') } + + if (!text) { out = cleanJson(out) } + + return out +} + +// JSON needs to get scrubbed from additional characters +// when being read from SpawnSync +const cleanJson = (out) => { + const o = out.substring(1) + .substring(0, out.length - 2) + .replace(pwdReg, '.') + + return JSON.parse(o) +} + +const textGetConfigKey = (out, key) => { + const newLineReturn = (isWin) ? '\r\n' : '\n' + const newLineRegEx = new RegExp(newLineReturn, 'g') + + let value = null + const keyReg = new RegExp(key + ':.+', 'g') + const matches = [...out.matchAll(keyReg)] + if (matches.length > 0 && typeof matches[0][0] === 'string') { + const fileName = matches[0][0].replace(newLineRegEx, '') + .replace(key + ':', '') + .replace(whiteSpaceReg, '') + .replace(/'/g, '') + value = fileName + } + + return value +} + +module.exports = { runSpawn, cleanJson, textGetConfigKey } diff --git a/test/print-config-unix.js.snap b/test/print-config-unix.js.snap new file mode 100644 index 00000000..2e303e9f --- /dev/null +++ b/test/print-config-unix.js.snap @@ -0,0 +1,54 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ensure valid json 1`] = ` +Object { + "100": false, + "all": false, + "allow-external": false, + "branches": 82, + "check-coverage": false, + "clean": true, + "config": "./.nycrc", + "exclude": Array [ + "coverage/**", + "packages/*/test{,s}/**", + "**/*.d.ts", + "test{,s}/**", + "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}", + "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}", + "**/__tests__/**", + "**/{ava,babel,nyc}.config.{js,cjs,mjs}", + "**/jest.config.{js,cjs,mjs,ts}", + "**/{karma,rollup,webpack}.config.js", + "**/.{eslint,mocha}rc.{js,cjs}", + ], + "exclude-after-remap": false, + "exclude-node-modules": true, + "extension": Array [ + ".js", + ".cjs", + ".mjs", + ".ts", + ".tsx", + ".jsx", + ], + "functions": 0, + "include": Array [], + "lines": 95, + "merge-async": false, + "omit-relative": true, + "per-file": false, + "print-config": true, + "print-config-format": "json", + "report-dir": "./coverage", + "reporter": Array [ + "html", + "text", + ], + "reports-dir": "./coverage", + "resolve": "", + "skip-full": false, + "statements": 95, + "temp-directory": "./coverage/tmp", +} +`; diff --git a/test/print-config-windows.js.snap b/test/print-config-windows.js.snap new file mode 100644 index 00000000..57d21080 --- /dev/null +++ b/test/print-config-windows.js.snap @@ -0,0 +1,54 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ensure valid json 1`] = ` +Object { + "100": false, + "all": false, + "allow-external": false, + "branches": 82, + "check-coverage": false, + "clean": true, + "config": ".\\\\.nycrc", + "exclude": Array [ + "coverage/**", + "packages/*/test{,s}/**", + "**/*.d.ts", + "test{,s}/**", + "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}", + "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}", + "**/__tests__/**", + "**/{ava,babel,nyc}.config.{js,cjs,mjs}", + "**/jest.config.{js,cjs,mjs,ts}", + "**/{karma,rollup,webpack}.config.js", + "**/.{eslint,mocha}rc.{js,cjs}", + ], + "exclude-after-remap": false, + "exclude-node-modules": true, + "extension": Array [ + ".js", + ".cjs", + ".mjs", + ".ts", + ".tsx", + ".jsx", + ], + "functions": 0, + "include": Array [], + "lines": 95, + "merge-async": false, + "omit-relative": true, + "per-file": false, + "print-config": true, + "print-config-format": "json", + "report-dir": "./coverage", + "reporter": Array [ + "html", + "text", + ], + "reports-dir": "./coverage", + "resolve": "", + "skip-full": false, + "statements": 95, + "temp-directory": ".\\\\coverage\\\\tmp", +} +`; diff --git a/test/print-config.js b/test/print-config.js new file mode 100644 index 00000000..3711a116 --- /dev/null +++ b/test/print-config.js @@ -0,0 +1,144 @@ +/* global describe, before, beforeEach, it */ + +const { rm } = require('fs') +const { runSpawn, textGetConfigKey } = require('./print-config-helpers') +const c8Path = require.resolve('../bin/c8') +const os = require('os') +const isWin = (os.platform() === 'win32') +const OsStr = (isWin) ? 'windows' : 'unix' +const chaiJestSnapshot = require('chai-jest-snapshot') +const { assert } = require('chai') + +require('chai').should() +require('chai') + .use(chaiJestSnapshot) + .should() + +before(cb => rm('tmp', { recursive: true, force: true }, cb)) + +beforeEach(function () { + chaiJestSnapshot.configureUsingMochaContext(this) +}) + +describe(`print derived configuration CLI option - ${OsStr}`, function () { + /** + * + * Test: Ensure Valid JSON + * Command: c8 --print-config --print-config-format=json + * + * ensure --print-config-format=json prints valid json document + */ + it('ensure valid json', function () { + chaiJestSnapshot.setTestName('ensure valid json') + chaiJestSnapshot.setFilename(`./test/print-config-${OsStr}.js.snap`) + + try { + const out = runSpawn([c8Path, '--print-config', '--print-config-format=json']) + out.should.matchSnapshot() + } catch (e) { + assert.fail('invalid json document produced from --print-config option') + } + }) + + /** + * + * Test: Ensure comma delimited values transform into an array + * Command: C8 --reporter=lcov,text --print-config --print-config-format=json + * + * Todo: There is a bug in yargs where this is not transformedd into an array + * Skipping test for now + */ + it('ensure comma delimited values transform into an array', function () { + this.skip() + const out = runSpawn([ + c8Path, + '--reporter=lcov,text', + '--print-config', + '--print-config-format=json' + ]) + + const includesKey = Object.keys(out).includes('reporter') + const checkFor = ['lcov', 'text'] + includesKey.should.eql(true) + out.reporter.should.eql(checkFor) + }) + + /** + * + * Test: Ensure default project configuration file is loaded + * Command: c8 --print-config + * + */ + it('ensure default project configuration file is loaded', function () { + const out = runSpawn([c8Path, '--print-config', '--print-config-format=json']) + + const includesKey = Object.keys(out).includes('config') + includesKey.should.eql(true) + out.config.endsWith('.nycrc') + }) + + ;['text', 'json'].forEach((format) => { + describe(`${format} format option`, function () { + // Can I shorten this line? + const textParam = (format === 'text') + + /** + * + * Test: ensure loads config file from cli + * Command: c8 -c ./test/fixtures/config/.c8rc.json --print-config --print-config-format=json|text + * + */ + it('ensure loads config file from cli', function () { + // Can I shorten this line? + const out = runSpawn([ + c8Path, + '--config=./test/fixtures/config/.c8rc.json', + '--print-config', + `--print-config-format=${format}` + ], textParam) + + if (format === 'json') { + const includesKey = Object.keys(out).includes('config') + includesKey.should.eql(true) + out.config.should.eql('./test/fixtures/config/.c8rc.json') + } else if (format === 'text') { + const value = textGetConfigKey(out, 'config') + if (value) { + value.should.eql('./test/fixtures/config/.c8rc.json') + } else { + assert.fail('couldn\'t find configuration value for option --config') + } + } + }) + + /** + * + * Test: Ensure loads reporter option from cli + * Command: c8 --reporter=lcov --print-config + * + */ + it('ensure loads reporter option from cli', function () { + const out = runSpawn([ + c8Path, + '--reporter=lcov', + '--print-config', + `--print-config-format=${format}` + ], textParam) + + if (format === 'json') { + const includesKey = Object.keys(out).includes('reporter') + includesKey.should.eql(true) + out.reporter.should.eql('lcov') + } else if (format === 'text') { + const value = textGetConfigKey(out, 'reporter') + if (value) { + // Todo: when the load comma delimited text array bug is fixed, need to adjust this line + value.should.eql('lcov') + } else { + assert.fail('couldn\'t find configuration value for option --reporter') + } + } + }) + }) + }) +}) From bbf5df8838ff90a6fe69c310b59278da83720fad Mon Sep 17 00:00:00 2001 From: "Trevor D. McKeown" Date: Sun, 4 Feb 2024 10:27:39 -0500 Subject: [PATCH 2/3] refactor: added print-config.js file refactor: moving banner art to a function with a template literal refactoring test/print-config.js unit tests refactor: deprecating chai should statements refactor: require statments order refactor: moved before hook to inside the describe block refactor: changed skip syntax refactor: print-format unit tests to be more concise refactor test/help-message.js refactor: deprecating should statements refactor: requires in the header of the file docs: Adding jdocs styled comments docs: refactor todo notes fix: deprecating replaceAll for replace fix: updating snapshots test: unit test to cover gap in formatPrintVariable function refactor: cleanUpArgumentArray to make logic more concise refactor: addressing a gap in coverage test: adding a unit test for cleanUpArgumentArray docs: updating todo items and noting a gap in coverage refactor: config table generation is now split up into functions refactor,docs: fixed spelling mistakes refactor: restricting the --print-config-format flag to either text or json refactor: changing the name of the interface from cleanUpArgumentArray to cleanUpArgumentObject docs: adding jsdocs to new functions in lib/print-config.js fix: unit test with cross platform path concerns docs: fixing spelling mistakes test: unit test for printConfigText to cover gap docs: doc block for "Test: ensure config prints without a config file" docs: updating the readme to include print config flags refactor: unit test for no config file - compressed snapshot refactor: print config display to add padding refactor: print config to dynamically draw certain lines docs: adding doc blocks to unit test refactor: changing name of test helpers function file refactor: eslint disable lines refactor: eslint disable lines fix: fixing snapshop error by removing dynamic display components test: updating snapshot on windows docs: add todo items, misc notes feat: added longestColumn function test: longestColumn unit test docs: fixed some errors in jsDocs. Added jsDocs for some functions. fix: Error in text rendering of configuration due to padding bug. refactor: printing of objects and arrays. left a todo item. fix: test case failing on number of columns in config table test: added a test to printing objects fix: an error where the graphic and summary were not centered docs: adding comments to runspawn function refactor: removing lines from cleanJson function refactor: update to windows snapshots docs: updating notes in test helpers. Finished a todo and added a todo refactor: removed cleanJson function in test helpers refactor: cleaned up runSpawn funtion if logic refactor: new windowsPathProcessing function refactor: simplifying runSpawn function test: new snapshots docs: windowsPathProcessing jsdocs block feat: runc8 function wrapper for runSpawn refactor: updated runSpawn interface to support additional options docs: removed reg ex todos --- README.md | 2 + c8-ascii-art.txt | 9 - lib/parse-args.js | 141 +---------- lib/print-config.js | 382 ++++++++++++++++++++++++++++++ test/help-message-unix.js.snap | 12 +- test/help-message-windows.js.snap | 12 +- test/help-message.js | 81 ++++--- test/integration.js.snap | 10 +- test/print-config-helpers.js | 75 ------ test/print-config-unix.js.snap | 2 + test/print-config-windows.js.snap | 2 + test/print-config.js | 270 ++++++++++++++++----- test/test-helpers.js | 175 ++++++++++++++ 13 files changed, 844 insertions(+), 329 deletions(-) delete mode 100644 c8-ascii-art.txt create mode 100644 lib/print-config.js delete mode 100644 test/print-config-helpers.js create mode 100644 test/test-helpers.js diff --git a/README.md b/README.md index a266a1da..6adce091 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ Here is a list of common options. Run `c8 --help` for the full list and document | `--per-file` | check thresholds per file | `boolean` | `false` | | `--temp-directory` | directory V8 coverage data is written to and read from | `string` | `process.env.NODE_V8_COVERAGE` | | `--clean` | should temp files be deleted before script execution | `boolean` | `true` | +| `--print-config` | prints the derived configuration between defaults and a detected configuration file or a file passed as an argument | `boolean` | `false` +| `--print-config-format` | format in which to print the derived configuration. Either text or json. | `string` | `text` ## Checking for "full" source coverage using `--all` diff --git a/c8-ascii-art.txt b/c8-ascii-art.txt deleted file mode 100644 index 51ce5f4f..00000000 --- a/c8-ascii-art.txt +++ /dev/null @@ -1,9 +0,0 @@ -/* ________/\\\\\\\\\_ _____/\\\\\\\\\____ */ -/* _____/\\\////////__ ___/\\\///////\\\__ */ -/* ___/\\\/___________ __\/\\\_____\/\\\__ */ -/* __/\\\_____________ __\///\\\\\\\\\/___ */ -/* _\/\\\_____________ ___/\\\///////\\\__ */ -/* _\//\\\____________ __/\\\______\//\\\_ */ -/* __\///\\\__________ _\//\\\______/\\\__ */ -/* ____\////\\\\\\\\\_ __\///\\\\\\\\\/___ */ -/* _______\/////////__ ____\/////////_____ */ \ No newline at end of file diff --git a/lib/parse-args.js b/lib/parse-args.js index 7e87d269..c7424125 100644 --- a/lib/parse-args.js +++ b/lib/parse-args.js @@ -7,6 +7,8 @@ const { applyExtends } = require('yargs/helpers') const parser = require('yargs-parser') const { resolve } = require('path') +const { printConfig } = require('./print-config.js') + function buildYargs (withCommands = false) { const yargs = Yargs([]) .usage('$0 [opts] [script] [opts]') @@ -167,6 +169,7 @@ function buildYargs (withCommands = false) { .options('print-config-format', { default: 'text', type: 'string', + choices: ['text', 'json'], describe: 'Format to print the configuration in. Accepted formats are either text or json' }) .pkgConf('c8') @@ -191,35 +194,7 @@ function buildYargs (withCommands = false) { // } // }) - const argv = process.argv.slice(2) - const checkArgs = parser(argv) - - let shouldPrint = false - - if (Object.keys(checkArgs).includes('print-config')) { - // checkArgs['print-config'] could contain a boolean or a string - // representing a boolean. - if (typeof checkArgs['print-config'] === 'boolean') { - shouldPrint = checkArgs['print-config'] - } else if (typeof checkArgs['print-config'] === 'string') { - shouldPrint = JSON.parse(checkArgs['print-config']) - } - } - - if (shouldPrint) { - const commandExecutedReference = 'c8 ' + argv.join(' ') - const args = yargs.parse(hideInstrumenteeArgs()) - const cleanArgs = cleanUpArgumentArray(args) - - if (args.printConfigFormat === 'text') { - printConfigText(cleanArgs, commandExecutedReference) - } else if (checkArgs.printConfigFormat === 'json') { - const jsonYargs = JSON.stringify(cleanArgs, 2) - console.log(jsonYargs) - } - - process.exit() - } + printConfig(yargs, hideInstrumenteeArgs) yargs.demandCommand(1) @@ -259,114 +234,6 @@ function hideInstrumenteeArgs () { return argv } -/** Todo: Refactor. Add jsdocs styled comments. Put functions below in their own file */ -// Todo: Take a look at Optimizing this function -// exclude certain temporary values and duplicates from printing -// the same variable will be included twice with different keys -// for example args['temp-directory'] && args['tempDirectory'] -// are essentially the same variable -function cleanUpArgumentArray (args) { - const argsToPrint = {} - Object.keys(args).forEach(v => { - if (v && v.length > 1 && v !== '_' && v !== '$0') { - // See if we are dealing with a Camel Case key string - const matches = [...v.matchAll(/([A-Z])/g)] - if (matches.length > 0) { - matches.forEach(m => { - // Derive Kebab Case string from Camel Case Key string - const newKey = m.input.replace(/([A-Z])/g, '-$1').toLowerCase() - // If the Kebab Case key is not assigned a value - if (!args[newKey]) { - // Then assigned it the Camel Case Variable - argsToPrint[newKey] = args[v] - } else if (!args[v]) { - // Other wise assign keep the Kebab Case key value - argsToPrint[newKey] = args[newKey] - } - }) - } else { - // Just keep the value. Either Kebab case or otherwise - argsToPrint[v] = args[v] - } - } - }) - - return argsToPrint -} - -function printConfigText (argsv, commandExecutedReference) { - /** - * Todo: Refactor: Put this line in a string literal - * - */ - const banner = readFileSync('./c8-ascii-art.txt', 'utf-8') - console.log('\n\n') - console.log(banner) - console.log('\n\n') - console.log('Command Issued: ' + commandExecutedReference) - console.log('Config File Loaded: ' + argsv.config + '\n\n\n') - console.log('Derived Configuration from CLI options and configuration file') - console.log('------------------------------------------------------------------------------') - /* End refactor note */ - - const addSpace = (numOfSpace) => { - let space = '' - for (let i = 0; i < numOfSpace; i++) space += ' ' - const s = space - return s - } - - /** Todo: Refactor: - * Put in a console.table format. - * - */ - // Including some formatting variables - // for spacing to make the output more readable - let output = '' - let spaceLength = Object.keys(argsv) - .map(v => String(v).length) - .reduce((p, c) => { - return (p >= c) ? p : c - }) - spaceLength += 10 - - // For each configuration value, print pretty - Object.keys(argsv).forEach(v => { - const fillSpace = addSpace(spaceLength - v.length) - const enumSpace = addSpace(spaceLength) - const value = formatPrintVariable(argsv[v], enumSpace) - output += String(v) + ':' + fillSpace + value + '\n' - }) - /** End Refactor */ - console.log(output) -} - -function formatPrintVariable (variable, space) { - let value - - if (Array.isArray(variable) && variable.length > 0) { - value = stringifyObject(variable, space, ']') - } else if (typeof variable === 'object' && Object.keys(variable).length > 0) { - value = stringifyObject(variable, space, '}') - } else if (typeof variable === 'string' && variable) { - value = "'" + variable + "'" - } else if (typeof variable === 'string' && !variable) { - value = "''" - } else { - value = variable - } - - return value -} - -function stringifyObject (variable, space, closingChar) { - const closeReg = new RegExp('\n' + closingChar, 'g') - const out = JSON.stringify(variable, null, '\t\t\t\t ') - .replace(closeReg, '\n' + space + ' ' + closingChar) - - return out -} - module.exports = { buildYargs, hideInstrumenterArgs, diff --git a/lib/print-config.js b/lib/print-config.js new file mode 100644 index 00000000..75132634 --- /dev/null +++ b/lib/print-config.js @@ -0,0 +1,382 @@ +const parser = require('yargs-parser') + +/** + * Function: printConfig + * + * @param {Object} yargs: instance of populated yargs object. + * @param {Function} hideInstrumenteeArgs: Callback defined in lib/parse-args. + * @returns {undefined} + * + * Entry point for print config logic from lib/parse-args.js file. + * Kills process at the end of execution. + * + */ +function printConfig (yargs, hideInstrumenteeArgs) { + const argv = process.argv.slice(2) + const checkArgs = parser(argv) + + let shouldPrint = false + + if (Object.keys(checkArgs).includes('print-config')) { + // checkArgs['print-config'] could contain a boolean or a string + // representing a boolean. + if (typeof checkArgs['print-config'] === 'boolean') { + shouldPrint = checkArgs['print-config'] + } else if (typeof checkArgs['print-config'] === 'string') { + shouldPrint = JSON.parse(checkArgs['print-config']) + } + } + + if (shouldPrint) { + const args = yargs.parse(hideInstrumenteeArgs()) + const cmdExecuted = 'c8 ' + argv.join(' ') + const cleanArgs = cleanUpArgumentObject(args) + + if (args.printConfigFormat === 'text') { + printConfigText(cleanArgs, cmdExecuted) + } else if (checkArgs.printConfigFormat === 'json') { + const jsonYargs = JSON.stringify(cleanArgs, 2) + console.log(jsonYargs) + } + + // DO NOT REMOVE! This is intentional. + process.exit() + } +} + +/** + * Function: cleanUpArgumentObject + * + * @param {Object} args: key/value pairs of configuration options + * generated by yargs.parse(). + * @returns {Object} - Clone of args with duplicated data removed. + * + * This function exclude duplicate values that have different keys. + * Additionally, scrubs convenience key values. + * + * For example: args['temp-directory'] and args['tempDirectory'] + * are essentially the same variable. + * + */ +function cleanUpArgumentObject (args) { + const argsToPrint = {} + + const keysToIterate = Object.keys(args).filter(v => { + return (!['_', '$0'].includes(v) && v.length > 1) + }) + + const camelCaseKeys = keysToIterate.filter(x => { + return [...x.matchAll(/([A-Z])/g)].length > 0 + }) + + keysToIterate.forEach(v => { + if (camelCaseKeys.includes(v)) { + // Derive Kebab Case string from Camel Case Key string + const newKey = v.replace(/([A-Z])/g, '-$1').toLowerCase() + // If the Kebab Case key is not assigned a value + if (!args[newKey]) { + // Then assigned it the Camel Case Variable + argsToPrint[newKey] = args[v] + } + } else { + // Just keep the value. Either Kebab case or otherwise + argsToPrint[v] = args[v] + } + // Not sure if we will hit this scenario + // should we throw an error? + }) + + return argsToPrint +} + +/** + * Function: printConfigText + * + * @param {Object} argsv: sanitized configuration option object. + * @param {String} cmdExecuted: the string representing the + * command for c8 that passed to the cli. + * @returns {undefined} + * + */ +function printConfigText (argsv, cmdExecuted) { + const configFilePath = argsv instanceof Object && + Object.keys(argsv).includes('config') && argsv.config + ? argsv.config + : '' + + // get the table string and add some padding + const tablePadding = ' ' + + // Adding padding to right side of table display + const table = printConfigTable(argsv, tablePadding) + + // find the line in the table with the most characters + const tableWidth = longestColumn(table) + + const description = printTableDescription(tableWidth, tablePadding) + + // get the banner string + const banner = printConfigBanner(cmdExecuted, configFilePath, tableWidth, tablePadding) + + // now print + console.log(banner) + console.log(description) + console.log(table) +} + +/** + * Function: printConfigBanner + * + * @param {String} cmdExecuted: the string representing the + * command for c8 that passed to the cli. + * @param {String} configFilePath: the absolute path to + * the configuration file that was loaded. + * @param {Number} tableWidth: the maximum table with measured by + * the number of characters. + * @param {String} tablePadding: a whitespace string to add as + * padding to the entire table. + * @returns {String} - the banner string to print. + * + * Todo: + * 1. Should I center this using the process.stdout.columns variable? + * + */ +function printConfigBanner (cmdExecuted, configFilePath, tableWidth, tablePadding) { + const graphic = String.raw` + + + /* ________/\\\\\\\\\_ _____/\\\\\\\\\____ */ + /* _____/\\\////////__ ___/\\\///////\\\__ */ + /* ___/\\\/___________ __\/\\\_____\/\\\__ */ + /* __/\\\_____________ __\///\\\\\\\\\/___ */ + /* _\/\\\_____________ ___/\\\///////\\\__ */ + /* _\//\\\____________ __/\\\______\//\\\_ */ + /* __\///\\\__________ _\//\\\______/\\\__ */ + /* ____\////\\\\\\\\\_ __\///\\\\\\\\\/___ */ + /* _______\/////////__ ____\/////////_____ */ + ` + + const graphicWidth = longestColumn(graphic) + + const graphicPaddingNum = Math.floor((tableWidth - graphicWidth) / 2) + const graphicPaddingStr = charString(graphicPaddingNum) + tablePadding + + const summery = String.raw` + Command Issued: ${cmdExecuted} + Config File Loaded: ${configFilePath} + + ` + + const reg = /\n{1} +/g + const replacement = '\n' + graphicPaddingStr + + const banner = graphic + summery + + return banner.replace(reg, replacement) +} + +/** + * Function: printTableDescription + * + * @param {Number} tableWidth: A number representing the column + * length of the configuration table. + * @param {String} tablePadding: a whitespace string to add as + * padding to the entire table. + * @returns {String} - A string representing the configuration + * table's description. + * + */ +function printTableDescription (tableWidth, tablePadding) { + const description = tablePadding + + 'Derived Configuration from CLI options and configuration file' + const line = '\n' + tablePadding + charString(tableWidth, '-') + '\n' + + return description + line +} + +/** + * Function: charString + * + * @param {Number} num: a digit for the number of character + * @returns {String} - a string with char repeated equal + * to the parameter num. + */ +function charString (num, char = ' ') { + let str = '' + for (let i = 0; i < num; i++) str += char + return str +} + +/** + * Function: printConfigTable + * + * @param {Object} args: An object of config params processed by + * cleanUpArgumentObject function. + * @param {String} tablePadding = '': A String representing the amount + * of right padding of the configuration value table. + * @returns {String} - A string representing the current configuration. + * + */ +function printConfigTable (args, tablePadding = '') { + let output = '' + const headerPadding = 10 + const headerColWidth = tableCalcHeaderWidth(args) + headerPadding + + Object.keys(args).forEach(v => { + const headerText = v + const value = args[v] + output += printConfigTableRow(headerText, value, headerColWidth, tablePadding) + }) + + return output +} + +/** + * Function: tableCalcHeaderWidth + * + * @param {Object} args: An object of config params processed by + * cleanUpArgumentObject function. + * @returns {Number} - An integer representing the max length of + * all keys assigned to the args object. + * + * + */ +function tableCalcHeaderWidth (args) { + return longestColumn(Object.keys(args)) +} + +/** + * Function: printConfigTableRow + * + * @param {String} header: a key in the arguments object. + * @param {any} value: a value in the arguments object. + * @param {Number} headerColWidth: max string length of keys in + * arguments object plus padding. + * @param {String} tablePadding: A String representing the amount + * of right padding of the configuration value table. + * @returns {String} - A rendered row of config table. + * + */ +function printConfigTableRow (header, value, headerColWidth, tablePadding) { + const { valueMargin, headerMargin } = + tableCalcRowMargin(headerColWidth, header, tablePadding) + + const val = formatPrintVariable(value, valueMargin) + const output = tablePadding + String(header) + ':' + headerMargin + val + '\n' + + return output +} + +/** + * Function: tableCalcRowMargin + * + * @param {Number} headerWidth: The width of the header column. + * @param {String} headerText: The value of the header column. + * @param {String} tablePadding: A String representing the amount + * of right padding of the configuration value table. + * @returns {Object} - An object containing whitespace string + * padding for the value and header columns. + * + */ +function tableCalcRowMargin (headerWidth, headerText, tablePadding) { + const rowHeaderLength = headerWidth - headerText.length + const rowHeaderMargin = charString(rowHeaderLength) + + const rowValueMargin = charString(headerWidth) + tablePadding + + return { + valueMargin: rowValueMargin, + headerMargin: rowHeaderMargin + } +} + +/** + * Function: formatPrintVariable + * + * @param {any} variable: the variable to format. + * @param {String} space: a string containing a variable + * amount of blank spaces. + * @returns {String} - string representation of the variable. + * + * + */ +function formatPrintVariable (vars, space) { + let value + + // Todo: I feel this would be easier to read a switch statement + if (vars instanceof Array && vars.length >= 1) { + value = stringifyObject(vars, space, ']') + } else if (vars instanceof Array && vars.length === 0) { + value = '[]' + } else if (vars instanceof Object && Object.keys(vars).length >= 1) { + value = stringifyObject(vars, space, '}') + } else if (vars instanceof Object && Object.keys(vars).length === 0) { + value = '{}' + } else if (typeof vars === 'string' && vars) { + value = "'" + vars + "'" + } else if (typeof vars === 'string' && !vars) { + value = "''" + } else { + value = vars + } + + return value +} + +/** + * Function: stringifyObject + * + * @param {any} variable: the variable to format. + * @param {String} space: string containing a variable + * amount of blank spaces. + * @param {String} closingChar: single string character + * either a ']' or a '}'. + * @returns {String} - string representation of the variable. + * + * + */ +function stringifyObject (variable, space, closingChar) { + const calcTabs = (spaces) => { + // 8 and 3 seem lie arbitrary numbers. A tab should + // equal 4 characters on all platforms. + const numOfTabs = Math.floor(spaces.length / 8) + const numOfSpaces = spaces.length % 8 + const tabs = charString(numOfTabs, '\t') + const remainingSpaces = charString(numOfSpaces + 3) + return tabs + remainingSpaces + } + + const jsonTabs = calcTabs(space) + + const closeReg = new RegExp('\n' + closingChar, 'g') + const out = JSON.stringify(variable, null, jsonTabs) + .replace(closeReg, '\n' + space + ' ' + closingChar) + + return out +} + +/** + * Function: longestColumn + * + * @param {Array|String} text: a string containing linefeed + * characters or an array containing no linefeed characters. + * @returns {Number} - a number representing the longest column + * width. + * + */ +function longestColumn (text) { + const compute = (text instanceof Array) + ? [...text] + : [...text.split('\n')] + + return compute.map(x => String(x).length) + .reduce((curr, prev) => curr >= prev ? curr : prev) +} + +module.exports = { + printConfig, + formatPrintVariable, + cleanUpArgumentObject, + printConfigText, + longestColumn +} diff --git a/test/help-message-unix.js.snap b/test/help-message-unix.js.snap index 33056bbc..d8ae2628 100644 --- a/test/help-message-unix.js.snap +++ b/test/help-message-unix.js.snap @@ -1,13 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`--print-config 1`] = `",/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-configConfigFileLoaded:./.nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile------------------------------------------------------------------------------100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'./.nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'./coverage/tmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text',"`; +exports[`--print-config 1`] = `"/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-configConfigFileLoaded:./.nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'./.nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:[]exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'./coverage/tmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text'"`; -exports[`--print-config=false 1`] = `",,c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\"./coverage/tmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereportersNotenoughnon-optionarguments:got0,needatleast1"`; +exports[`--print-config=false 1`] = `""`; -exports[`--print-config=false 2`] = `",zeropositivenegative--------------|---------|----------|---------|---------|-------------------File|%Stmts|%Branch|%Funcs|%Lines|UncoveredLine#s--------------|---------|----------|---------|---------|-------------------Allfiles|64.28|66.66|50|64.28|vanilla|78.26|75|100|78.26|loaded.js|73.68|71.42|100|73.68|4-5,16-18main.js|100|100|100|100|vanilla/dir|0|0|0|0|unloaded.js|0|0|0|0|1-5--------------|---------|----------|---------|---------|-------------------,"`; +exports[`--print-config=false 2`] = `"zeropositivenegative--------------|---------|----------|---------|---------|-------------------File|%Stmts|%Branch|%Funcs|%Lines|UncoveredLine#s--------------|---------|----------|---------|---------|-------------------Allfiles|64.28|66.66|50|64.28|vanilla|78.26|75|100|78.26|loaded.js|73.68|71.42|100|73.68|4-5,16-18main.js|100|100|100|100|vanilla/dir|0|0|0|0|unloaded.js|0|0|0|0|1-5--------------|---------|----------|---------|---------|-------------------"`; -exports[`--print-config=true 1`] = `",/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-config=trueConfigFileLoaded:./.nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile------------------------------------------------------------------------------100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'./.nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'./coverage/tmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text',"`; +exports[`--print-config=true 1`] = `"/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-config=trueConfigFileLoaded:./.nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'./.nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:[]exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'./coverage/tmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text'"`; -exports[`ensure the help message is correct 1`] = `",c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\"./coverage/tmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereporters,"`; +exports[`ensure the help message is correct 1`] = `"c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\"./coverage/tmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][choices:\\"text\\",\\"json\\"][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereporters"`; -exports[`ensure warning message 1`] = `",,c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\"./coverage/tmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereportersNotenoughnon-optionarguments:got0,needatleast1"`; +exports[`ensure warning message 1`] = `""`; diff --git a/test/help-message-windows.js.snap b/test/help-message-windows.js.snap index 48a41fc9..9743fdb9 100644 --- a/test/help-message-windows.js.snap +++ b/test/help-message-windows.js.snap @@ -1,13 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`--print-config 1`] = `",/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-configConfigFileLoaded:..nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile------------------------------------------------------------------------------100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'..nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'.coveragetmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text',"`; +exports[`--print-config 1`] = `"/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-configConfigFileLoaded:..nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'..nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:[]exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'.coveragetmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text'"`; -exports[`--print-config=false 1`] = `",,c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\".coveragetmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereportersNotenoughnon-optionarguments:got0,needatleast1"`; +exports[`--print-config=false 1`] = `""`; -exports[`--print-config=false 2`] = `",zeropositivenegative--------------|---------|----------|---------|---------|-------------------File|%Stmts|%Branch|%Funcs|%Lines|UncoveredLine#s--------------|---------|----------|---------|---------|-------------------Allfiles|64.28|66.66|50|64.28|vanilla|78.26|75|100|78.26|loaded.js|73.68|71.42|100|73.68|4-5,16-18main.js|100|100|100|100|vanilla/dir|0|0|0|0|unloaded.js|0|0|0|0|1-5--------------|---------|----------|---------|---------|-------------------,"`; +exports[`--print-config=false 2`] = `"zeropositivenegative--------------|---------|----------|---------|---------|-------------------File|%Stmts|%Branch|%Funcs|%Lines|UncoveredLine#s--------------|---------|----------|---------|---------|-------------------Allfiles|64.28|66.66|50|64.28|vanilla|78.26|75|100|78.26|loaded.js|73.68|71.42|100|73.68|4-5,16-18main.js|100|100|100|100|vanilla/dir|0|0|0|0|unloaded.js|0|0|0|0|1-5--------------|---------|----------|---------|---------|-------------------"`; -exports[`--print-config=true 1`] = `",/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-config=trueConfigFileLoaded:..nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile------------------------------------------------------------------------------100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'..nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'.coveragetmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text',"`; +exports[`--print-config=true 1`] = `"/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--print-config=trueConfigFileLoaded:..nycrcDerivedConfigurationfromCLIoptionsandconfigurationfile100:falseprint-config:truereporter:[\\"html\\",\\"text\\"]lines:95branches:82statements:95config:'..nycrc'reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:[]exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'.coveragetmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text'"`; -exports[`ensure the help message is correct 1`] = `",c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\".coveragetmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereporters,"`; +exports[`ensure the help message is correct 1`] = `"c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\".coveragetmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][choices:\\"text\\",\\"json\\"][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereporters"`; -exports[`ensure warning message 1`] = `",,c8.js[opts][script][opts]Commands:c8.jscheck-coveragecheckwhethercoverageiswithinthresholdsprovidedc8.jsreportreadV8coveragedatafromtempandoutputreportReportingoptions-r,--reportercoveragereporter(s)touse[default:\\"text\\"]-o,--reports-dir,--report-dirdirectorywherecoveragereportswillbeoutputto[default:\\"./coverage\\"]--allsupplying--allwillcausec8toconsiderallsrcfilesinthecurrentworkingdirectorywhenthedeterminingcoverage.Respectsinclude/exclude.[boolean][default:false]--srcsupplying--srcwilloverridecwdasthedefaultlocationwhere--alllooksforsrcfiles.--srccanbesuppliedmultipletimesandeachdirectorywillbeincluded.Thisallowsforworkspacesspanningmultipleprojects[string]-n,--includealistofspecificfilesthatshouldbecovered(globpatternsaresupported)[default:[]]-x,--excludealistofspecificfilesanddirectoriesthatshouldbeexcludedfromcoverage(globpatternsaresupported)[default:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]]-e,--extensionalistofspecificfileextensionsthatshouldbecovered[default:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]]-a,--exclude-after-remapapplyexcludelogictofilesaftertheyareremappedbyasource-map[boolean][default:false]--skip-fulldonotshowfileswith100%statement,branch,andfunctioncoverage[boolean][default:false]Coveragethresholds--check-coveragecheckwhethercoverageiswithinthresholdsprovided[boolean][default:false]--brancheswhat%ofbranchesmustbecovered?[number][default:0]--functionswhat%offunctionsmustbecovered?[number][default:0]--lineswhat%oflinesmustbecovered?[number][default:90]--statementswhat%ofstatementsmustbecovered?[number][default:0]--per-filecheckthresholdsperfile[boolean][default:false]--100shortcutfor--check-coverage--lines100--functions100--branches100--statements100[boolean][default:false]Options:--helpShowhelp[boolean]--versionShowversionnumber[boolean]-c,--configpathtoJSONconfigurationfile[default:(default)]--exclude-node-moduleswhetherornottoexcludeallnode_modulefolders(i.e.**/node_modules/**)bydefault[boolean][default:true]--temp-directorydirectoryV8coveragedataiswrittentoandreadfrom[default:\\".coveragetmp\\"]--cleanshouldtempfilesbedeletedbeforescriptexecution[boolean][default:true]--resolveresolvepathstoalternatebasedirectory[default:\\"\\"]--wrapper-lengthhowmanybytesisthewrapperprefixonexecutedJavaScript[number]--omit-relativeomitanypathsthatarenotabsolute,e.g.,internal/net.js[boolean][default:true]--allowExternalsupplying--allowExternalwillcausec8toallowfilesfromoutsideofyourcwd.Thisappliesbothtofilesdiscoveredincoveragetempfilesandalsosrcfilesdiscoveredifusingthe--allflag.[boolean][default:false]--merge-asyncsupplying--merge-asyncwillmergeallv8coveragereportsasynchronouslyandincrementally.ThisistoavoidOOMissueswithNode.jsruntime.[boolean][default:false]--print-configPrintthederivedconfigurationbetweencommandlineparametersandloadedconfigurationfile[boolean][default:false]--print-config-formatFormattoprinttheconfigurationin.Acceptedformatsareeithertextorjson[string][default:\\"text\\"]visithttps://git.io/vHysAforlistofavailablereportersNotenoughnon-optionarguments:got0,needatleast1"`; +exports[`ensure warning message 1`] = `""`; diff --git a/test/help-message.js b/test/help-message.js index 0f162812..ef8474fc 100644 --- a/test/help-message.js +++ b/test/help-message.js @@ -1,28 +1,21 @@ -/* global describe, before, beforeEach, it */ +/* global describe, before, it */ -const { runSpawn } = require('./print-config-helpers') -const c8Path = require.resolve('../bin/c8') const { rm } = require('fs') const os = require('os') -const isWin = (os.platform() === 'win32') -const OsStr = (isWin) ? 'windows' : 'unix' -const shouldCompressSnapShot = true -const nodePath = process.execPath - const chaiJestSnapshot = require('chai-jest-snapshot') -require('chai').should() + +const { runc8 } = require('./test-helpers') +const { expect } = require('chai') + require('chai') .use(chaiJestSnapshot) - .should() -before(cb => rm('tmp', { recursive: true, force: true }, cb)) - -beforeEach(function () { - chaiJestSnapshot.configureUsingMochaContext(this) -}) +const shouldCompressSnapShot = true +const isWin = (os.platform() === 'win32') +const OsStr = (isWin) ? 'windows' : 'unix' describe(`Help Message - ${OsStr}`, function () { - // Ensure the help message is correct - Snapshot of help message + before(cb => rm('tmp', { recursive: true, force: true }, cb)) /** * Test: Ensure Help Message is Correct * Command: c8 --help @@ -32,9 +25,13 @@ describe(`Help Message - ${OsStr}`, function () { it('ensure the help message is correct', function () { chaiJestSnapshot.setTestName('ensure the help message is correct') chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) - const output = runSpawn([c8Path, '--help'], true, shouldCompressSnapShot) - output.should.matchSnapshot() + const opts = Object.freeze({ + stripWhiteSpace: shouldCompressSnapShot + }) + const output = runc8('--help', opts) + + expect(output).to.matchSnapshot() }) describe('should demand arguments', function () { @@ -48,9 +45,13 @@ describe(`Help Message - ${OsStr}`, function () { it('ensure warning message', function () { chaiJestSnapshot.setTestName('ensure warning message') chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) - const output = runSpawn([c8Path], true, shouldCompressSnapShot) - output.should.matchSnapshot() + const opts = Object.freeze({ + stripWhiteSpace: shouldCompressSnapShot + }) + const output = runc8('', opts) + + expect(output).to.matchSnapshot() }) /** @@ -62,8 +63,12 @@ describe(`Help Message - ${OsStr}`, function () { it('--print-config=false', function () { chaiJestSnapshot.setTestName('--print-config=false') chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) - const out = runSpawn([c8Path, '--print-config=false'], true, shouldCompressSnapShot) - out.should.matchSnapshot() + + const opts = Object.freeze({ + stripWhiteSpace: shouldCompressSnapShot + }) + const output = runc8('--print-config=false', opts) + expect(output).to.matchSnapshot() }) }) @@ -79,8 +84,14 @@ describe(`Help Message - ${OsStr}`, function () { it('--print-config=true', function () { chaiJestSnapshot.setTestName('--print-config=true') chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) - const out = runSpawn([c8Path, '--print-config=true'], true, shouldCompressSnapShot) - out.should.matchSnapshot() + + const opts = Object.freeze({ + stripWhiteSpace: shouldCompressSnapShot, + removeBannerDivider: true + }) + + const output = runc8('--print-config=true', opts) + expect(output).to.matchSnapshot() }) /** @@ -95,8 +106,14 @@ describe(`Help Message - ${OsStr}`, function () { it('--print-config', function () { chaiJestSnapshot.setTestName('--print-config') chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) - const out = runSpawn([c8Path, '--print-config'], true, shouldCompressSnapShot) - out.should.matchSnapshot() + + const opts = Object.freeze({ + stripWhiteSpace: shouldCompressSnapShot, + removeBannerDivider: true + }) + + const output = runc8('--print-config', opts) + expect(output).to.matchSnapshot() }) /** @@ -108,10 +125,11 @@ describe(`Help Message - ${OsStr}`, function () { * */ it('--print-config=false', function () { + const nodePath = process.execPath + chaiJestSnapshot.setTestName('--print-config=false') chaiJestSnapshot.setFilename(`./test/help-message-${OsStr}.js.snap`) const args = [ - c8Path, '--print-config=false', '--temp-directory=tmp/vanilla-all', '--clean=false', @@ -121,8 +139,13 @@ describe(`Help Message - ${OsStr}`, function () { nodePath, require.resolve('./fixtures/all/vanilla/main') ] - const out = runSpawn(args, true, shouldCompressSnapShot) - out.should.matchSnapshot() + + const opts = Object.freeze({ + stripWhiteSpace: shouldCompressSnapShot + }) + + const output = runc8(args, opts) + expect(output).to.matchSnapshot() }) }) }) diff --git a/test/integration.js.snap b/test/integration.js.snap index 9cfdd3c1..94e8f394 100644 --- a/test/integration.js.snap +++ b/test/integration.js.snap @@ -156,7 +156,7 @@ hey ---------------------------------------|---------|----------|---------|---------|------------------------ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ---------------------------------------|---------|----------|---------|---------|------------------------ -All files | 3.24 | 12.5 | 6.52 | 3.24 | +All files | 2.82 | 12.24 | 6.38 | 2.82 | c8 | 0 | 0 | 0 | 0 | index.js | 0 | 0 | 0 | 0 | 1 c8/bin | 0 | 0 | 0 | 0 | @@ -166,7 +166,8 @@ All files | 3.24 | 12.5 | 6.52 | 3.24 prettify.js | 0 | 0 | 0 | 0 | 1-2 sorter.js | 0 | 0 | 0 | 0 | 1-196 c8/lib | 0 | 0 | 0 | 0 | - parse-args.js | 0 | 0 | 0 | 0 | 1-362 + parse-args.js | 0 | 0 | 0 | 0 | 1-241 + print-config.js | 0 | 0 | 0 | 0 | 1-382 report.js | 0 | 0 | 0 | 0 | 1-402 source-map-from-file.js | 0 | 0 | 0 | 0 | 1-100 c8/lib/commands | 0 | 0 | 0 | 0 | @@ -521,7 +522,7 @@ hey ---------------------------------------|---------|----------|---------|---------|------------------------ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ---------------------------------------|---------|----------|---------|---------|------------------------ -All files | 3.24 | 12.5 | 6.52 | 3.24 | +All files | 2.82 | 12.24 | 6.38 | 2.82 | c8 | 0 | 0 | 0 | 0 | index.js | 0 | 0 | 0 | 0 | 1 c8/bin | 0 | 0 | 0 | 0 | @@ -531,7 +532,8 @@ All files | 3.24 | 12.5 | 6.52 | 3.24 prettify.js | 0 | 0 | 0 | 0 | 1-2 sorter.js | 0 | 0 | 0 | 0 | 1-196 c8/lib | 0 | 0 | 0 | 0 | - parse-args.js | 0 | 0 | 0 | 0 | 1-362 + parse-args.js | 0 | 0 | 0 | 0 | 1-241 + print-config.js | 0 | 0 | 0 | 0 | 1-382 report.js | 0 | 0 | 0 | 0 | 1-402 source-map-from-file.js | 0 | 0 | 0 | 0 | 1-100 c8/lib/commands | 0 | 0 | 0 | 0 | diff --git a/test/print-config-helpers.js b/test/print-config-helpers.js deleted file mode 100644 index 3fe6de5c..00000000 --- a/test/print-config-helpers.js +++ /dev/null @@ -1,75 +0,0 @@ -const { spawnSync } = require('child_process') -const os = require('os') - -const nodePath = process.execPath -const isWin = (os.platform() === 'win32') -const pwd = process.cwd() -const whiteSpaceReg = /[\\\s]/g -const pwdReg = new RegExp(pwd, 'g') - -const runSpawn = (args, text = false, stripWhiteSpace = false) => { - const doubleQuoteReg = /"/g - const slashReg = /\\/g - - const { output } = spawnSync(nodePath, args) - - let out = output.toString('utf8') - - if (isWin && text) { - const jsonEncodedPwd = JSON.stringify(pwd) - .replace(doubleQuoteReg, '') - const encodedPwdRegEx = new RegExp(jsonEncodedPwd, 'g') - out = out.replace(encodedPwdRegEx, '.') - } else if (isWin && !text) { - const jsonEncodedPwd = JSON.stringify(pwd) - .replace(doubleQuoteReg, '') - .replace(slashReg, '\\\\') - const encodedPwdRegEx = new RegExp(jsonEncodedPwd, 'g') - out = out.replace(encodedPwdRegEx, '.') - } else if (!isWin) { - out = out.replace(pwdReg, '.') - } - - // For certain cases we need to strip out all whitespace in - // snapshots. It's not ideal and it makes it hard to read - // but I am concern about this issue in the chai-snapshot - // package - // - // https://github.com/jestjs/jest/pull/9203 - - if (text && stripWhiteSpace) { out = out.replace(whiteSpaceReg, '') } - - if (!text) { out = cleanJson(out) } - - return out -} - -// JSON needs to get scrubbed from additional characters -// when being read from SpawnSync -const cleanJson = (out) => { - const o = out.substring(1) - .substring(0, out.length - 2) - .replace(pwdReg, '.') - - return JSON.parse(o) -} - -const textGetConfigKey = (out, key) => { - const newLineReturn = (isWin) ? '\r\n' : '\n' - const newLineRegEx = new RegExp(newLineReturn, 'g') - - let value = null - const keyReg = new RegExp(key + ':.+', 'g') - const matches = [...out.matchAll(keyReg)] - if (matches.length > 0 && typeof matches[0][0] === 'string') { - const fileName = matches[0][0].replace(newLineRegEx, '') - .replace(key + ':', '') - .replace(whiteSpaceReg, '') - .replace(/'/g, '') - value = fileName - } - - return value -} - -module.exports = { runSpawn, cleanJson, textGetConfigKey } diff --git a/test/print-config-unix.js.snap b/test/print-config-unix.js.snap index 2e303e9f..07689ece 100644 --- a/test/print-config-unix.js.snap +++ b/test/print-config-unix.js.snap @@ -1,5 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`ensure config prints without a config file 1`] = `"/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--config=\\"\\"--print-config--lines100ConfigFileLoaded:DerivedConfigurationfromCLIoptionsandconfigurationfile100:falseconfig:''print-config:truelines:100reporter:[\\"html\\",\\"text\\"]branches:82statements:95reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:[]exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'./coverage/tmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text'"`; + exports[`ensure valid json 1`] = ` Object { "100": false, diff --git a/test/print-config-windows.js.snap b/test/print-config-windows.js.snap index 57d21080..7c765fc6 100644 --- a/test/print-config-windows.js.snap +++ b/test/print-config-windows.js.snap @@ -1,5 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`ensure config prints without a config file 1`] = `"/*________/______/____*//*_____/////////_____////////__*//*___//_____________/_____/__*//*__/_______________////___*//*_/________________////////__*//*_//______________/______//_*//*__///___________//______/__*//*____////___////___*//*_______/////////______/////////_____*/CommandIssued:c8--config=\\"\\"--print-config--lines100ConfigFileLoaded:DerivedConfigurationfromCLIoptionsandconfigurationfile100:falseconfig:''print-config:truelines:100reporter:[\\"html\\",\\"text\\"]branches:82statements:95reports-dir:'./coverage'report-dir:'./coverage'all:falsesrc:undefinedexclude-node-modules:trueinclude:[]exclude:[\\"coverage/**\\",\\"packages/*/test{,s}/**\\",\\"**/*.d.ts\\",\\"test{,s}/**\\",\\"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}\\",\\"**/__tests__/**\\",\\"**/{ava,babel,nyc}.config.{js,cjs,mjs}\\",\\"**/jest.config.{js,cjs,mjs,ts}\\",\\"**/{karma,rollup,webpack}.config.js\\",\\"**/.{eslint,mocha}rc.{js,cjs}\\"]extension:[\\".js\\",\\".cjs\\",\\".mjs\\",\\".ts\\",\\".tsx\\",\\".jsx\\"]exclude-after-remap:falseskip-full:falsecheck-coverage:falsefunctions:0per-file:falsetemp-directory:'.coveragetmp'clean:trueresolve:''omit-relative:trueallow-external:falsemerge-async:falseprint-config-format:'text'"`; + exports[`ensure valid json 1`] = ` Object { "100": false, diff --git a/test/print-config.js b/test/print-config.js index 3711a116..663cea91 100644 --- a/test/print-config.js +++ b/test/print-config.js @@ -1,26 +1,31 @@ -/* global describe, before, beforeEach, it */ +/* global describe, before, it */ const { rm } = require('fs') -const { runSpawn, textGetConfigKey } = require('./print-config-helpers') -const c8Path = require.resolve('../bin/c8') const os = require('os') -const isWin = (os.platform() === 'win32') -const OsStr = (isWin) ? 'windows' : 'unix' +const { expect } = require('chai') +const { resolve } = require('path') const chaiJestSnapshot = require('chai-jest-snapshot') -const { assert } = require('chai') -require('chai').should() -require('chai') - .use(chaiJestSnapshot) - .should() +const { + runc8, + textGetConfigKey +} = require('./test-helpers') -before(cb => rm('tmp', { recursive: true, force: true }, cb)) +const { + formatPrintVariable, + cleanUpArgumentObject, + longestColumn +} = require('../lib/print-config') -beforeEach(function () { - chaiJestSnapshot.configureUsingMochaContext(this) -}) +const { buildYargs } = require('../lib/parse-args') +require('chai') + .use(chaiJestSnapshot) + +const isWin = (os.platform() === 'win32') +const OsStr = (isWin) ? 'windows' : 'unix' describe(`print derived configuration CLI option - ${OsStr}`, function () { + before(cb => rm('tmp', { recursive: true, force: true }, cb)) /** * * Test: Ensure Valid JSON @@ -32,12 +37,11 @@ describe(`print derived configuration CLI option - ${OsStr}`, function () { chaiJestSnapshot.setTestName('ensure valid json') chaiJestSnapshot.setFilename(`./test/print-config-${OsStr}.js.snap`) - try { - const out = runSpawn([c8Path, '--print-config', '--print-config-format=json']) - out.should.matchSnapshot() - } catch (e) { - assert.fail('invalid json document produced from --print-config option') - } + const opts = Object.freeze({ + expectedOutput: 'json' + }) + const out = runc8(['--print-config', '--print-config-format=json'], opts) + expect(out).to.matchSnapshot() }) /** @@ -45,22 +49,21 @@ describe(`print derived configuration CLI option - ${OsStr}`, function () { * Test: Ensure comma delimited values transform into an array * Command: C8 --reporter=lcov,text --print-config --print-config-format=json * - * Todo: There is a bug in yargs where this is not transformedd into an array + * Todo: There is a bug in yargs where this is not transformed into an array * Skipping test for now */ - it('ensure comma delimited values transform into an array', function () { - this.skip() - const out = runSpawn([ - c8Path, + it.skip('ensure comma delimited values transform into an array', function () { + const opts = Object.freeze({ + expectedOutput: 'json' + }) + const out = runc8([ '--reporter=lcov,text', '--print-config', '--print-config-format=json' - ]) + ], opts) - const includesKey = Object.keys(out).includes('reporter') - const checkFor = ['lcov', 'text'] - includesKey.should.eql(true) - out.reporter.should.eql(checkFor) + expect(Object.keys(out).includes('reporter')).to.equal(true) + expect(out.reporter).to.eql(['lcov', 'text']) }) /** @@ -70,17 +73,18 @@ describe(`print derived configuration CLI option - ${OsStr}`, function () { * */ it('ensure default project configuration file is loaded', function () { - const out = runSpawn([c8Path, '--print-config', '--print-config-format=json']) + const opts = Object.freeze({ + expectedOutput: 'json' + }) + const out = runc8(['--print-config', '--print-config-format=json'], opts) - const includesKey = Object.keys(out).includes('config') - includesKey.should.eql(true) + expect(Object.keys(out).includes('config')).to.equal(true) out.config.endsWith('.nycrc') }) ;['text', 'json'].forEach((format) => { describe(`${format} format option`, function () { - // Can I shorten this line? - const textParam = (format === 'text') + const textParam = format === 'text' /** * @@ -90,25 +94,32 @@ describe(`print derived configuration CLI option - ${OsStr}`, function () { */ it('ensure loads config file from cli', function () { // Can I shorten this line? - const out = runSpawn([ - c8Path, - '--config=./test/fixtures/config/.c8rc.json', + const configFile = './test/fixtures/config/.c8rc.json' + const opts = Object.freeze({ + expectedOutput: textParam ? 'text' : 'json' + }) + + const out = runc8([ + `--config=${configFile}`, '--print-config', `--print-config-format=${format}` - ], textParam) + ], opts) + let value if (format === 'json') { - const includesKey = Object.keys(out).includes('config') - includesKey.should.eql(true) - out.config.should.eql('./test/fixtures/config/.c8rc.json') - } else if (format === 'text') { - const value = textGetConfigKey(out, 'config') - if (value) { - value.should.eql('./test/fixtures/config/.c8rc.json') - } else { - assert.fail('couldn\'t find configuration value for option --config') - } + expect(Object.keys(out) + .includes('config')).to.equal(true) + value = out.config + } else { + value = textGetConfigKey(out, 'config') + } + + if (!value) { + expect + .fail('couldn\'t find configuration value for option --config') } + + expect(value).to.eql(configFile) }) /** @@ -118,27 +129,160 @@ describe(`print derived configuration CLI option - ${OsStr}`, function () { * */ it('ensure loads reporter option from cli', function () { - const out = runSpawn([ - c8Path, + const opts = Object.freeze({ + expectedOutput: textParam ? 'text' : 'json' + }) + + const out = runc8([ '--reporter=lcov', '--print-config', `--print-config-format=${format}` - ], textParam) + ], opts) + let value if (format === 'json') { - const includesKey = Object.keys(out).includes('reporter') - includesKey.should.eql(true) - out.reporter.should.eql('lcov') - } else if (format === 'text') { - const value = textGetConfigKey(out, 'reporter') - if (value) { - // Todo: when the load comma delimited text array bug is fixed, need to adjust this line - value.should.eql('lcov') - } else { - assert.fail('couldn\'t find configuration value for option --reporter') - } + expect(Object.keys(out) + .includes('reporter')).to.equal(true) + value = out.reporter + } else { + value = textGetConfigKey(out, 'reporter') } + + if (!value) { + expect + .fail('couldn\'t find configuration value for option --reporter') + } + + // Todo: when the load comma delimited text array bug is fixed, need to adjust this line + expect(value).to.eql('lcov') }) }) }) + + /** + * Test: ensure objects can be printed in derived config display + * + * a unit test to ensure coverage of printed objects + */ + it('ensure objects can be printed in derived config display', function () { + let testObject = { + a: 'str1', + b: 4, + c: false, + d: undefined, + e: null, + f: ['one', 'two', 'three'], + g: { + five: 'six', + seven: false, + eight: [ + { + nine: 9, + ten: '10' + }, + { + eleven: true, + twelve: null + } + ] + } + } + + let output = formatPrintVariable(testObject, '').replace(/\s+/g, '') + let expected = '{"a":"str1","b":4,"c":false,"e":null,"f":["one","two","three"],' + + '"g":{"five":"six","seven":false,"eight":[{"nine":9,"ten":"10"},' + + '{"eleven":true,"twelve":null}]}}' + + expect(output).to.equal(expected) + + testObject = {} + output = formatPrintVariable(testObject, '').replace(/\s+/g, '') + expected = '{}' + expect(output).to.equal(expected) + }) + + /** + * Test: testing cleanUpArgumentObject function + * + * Just a unit test that helped develop the function + */ + it('testing cleanUpArgumentObject function', function () { + const args = Object.freeze([ + 'node', + 'c8', + '--print-config', + '--lines', + '100', + '--config', + require.resolve('./fixtures/config/.c8rc.json') + ]) + const argsv = buildYargs().parse(args) + const cleanArgs = cleanUpArgumentObject(argsv) + + const configPath = resolve('./test/fixtures/config/.c8rc.json') + + expect(cleanArgs.config).to.equal(configPath) + + const noCamelCaseKeys = Object.keys(cleanArgs) + .map(v => [...v.matchAll(/([A-Z])/g)].length === 0) + .reduce((prev, curr) => prev && curr) + + expect(noCamelCaseKeys).to.eql(true) + }) + + /** + * Test: ensure config prints without a config file + * + * Run the printConfigText function with an empty string + * assigned to the config key and expect the configuration + * to still print. + * + */ + it('ensure config prints without a config file', function () { + chaiJestSnapshot.setTestName('ensure config prints without a config file') + chaiJestSnapshot.setFilename(`./test/print-config-${OsStr}.js.snap`) + + const args = Object.freeze([ + '--config=""', + '--print-config', + '--lines', + '100' + ]) + + const opts = Object.freeze({ + stripWhiteSpace: true, + removeBannerDivider: true + }) + + // run the process, get the output and remove + // items that are dynamically formatted. + const output = runc8(args, opts) + + expect(output).to.matchSnapshot() + }) + + /** + * Test: ensure longestColumn can be passed an array + * + */ + it('ensure longestColumn can be passed an array', function () { + const args = Object.freeze([ + '--config=""', + '--print-config', + '--lines', + '100' + ]) + + const opts = Object.freeze({ + stripWhiteSpace: false, + removeBannerDivider: true + }) + + // run the process, get the output and remove + // items that are dynamically formatted. + const output = runc8(args, opts) + + const width = longestColumn(output.split('\n')) + expect(width).to.be.gte(62) + }) }) diff --git a/test/test-helpers.js b/test/test-helpers.js new file mode 100644 index 00000000..2a09ef96 --- /dev/null +++ b/test/test-helpers.js @@ -0,0 +1,175 @@ +const { spawnSync } = require('child_process') +const os = require('os') + +const isWin = (os.platform() === 'win32') +const pwd = process.cwd() +const whiteSpaceReg = /[\\\s]/g + +/** + * Function: runc8 + * + * @param {Array|String} args: an array of arguments or a string argument + * to pass to child spawned process. + * @param {Object} options: an Object with the following key-values + * {Object} spawnSyncOptions: The options object found here. http://tinyurl.com/66ztyx9b + * {String} expectedOutput: either 'text' or 'json' - default 'json' + * {Boolean} stripWhiteSpace: Should the output returned be stripped of all whitespace. + * - default false + * {Boolean} removeBannerDivider: Should remove the divider line below the config + * report banner - default false + * @returns {String} out: a string representing the stdout + * of the child process + * + * + */ +const runc8 = (args, options) => { + const nodePath = process.execPath + const c8Path = require.resolve('../bin/c8') + const argsv = (typeof args === 'string') + ? [c8Path, args] + : [c8Path, ...args] + + return runSpawn(nodePath, argsv, options) +} + +/** + * Function: runSpawn + * + * @param {String} cmd: A string representing the prompt command + * @param {Array|String} args: An array of arguments or a string argument + * to pass to child spawned process. + * @param {Object} options: an Object with the following key-values + * {Object} spawnSyncOptions: The options object found here. http://tinyurl.com/66ztyx9b + * {String} expectedOutput: either 'text' or 'json' - default 'json' + * {Boolean} stripWhiteSpace: Should the output returned be stripped of all whitespace. + * - default false + * {Boolean} removeBannerDivider: Should remove the divider line below the config + * report banner - default false + * @returns {String} out: a string representing the stdout + * of the child process + * + * A wrapper function around spawnSync. + * Node.js Docs: http://tinyurl.com/66ztyx9b + * + * Todo: Whitespace for snapshots is showing up in + * different amounts on different os platforms. + * + * I am concern about this issue in the chai-snapshot + * package. + * + * Issue described in jest + * https://github.com/jestjs/jest/pull/9203 + * + * Last time chai-jest-snapshot was publish was 6 + * years ago. + * + * https://www.npmjs.com/package/chai-jest-snapshot?activeTab=versions + * + * Alternative packages that might work. + * + * https://www.npmjs.com/package/mocha-chai-jest-snapshot + * + * https://www.npmjs.com/package/chai-snapshot-matcher/v/2.0.2 + * + */ +const runSpawn = (cmd, args, options = {}) => { + const opts = Object.freeze(Object.assign({ + expectedOutput: 'text', + stripWhiteSpace: false, + removeBannerDivider: false, + spawnSyncOptions: {} + }, options)) + + const { + expectedOutput, + stripWhiteSpace, + spawnSyncOptions, + removeBannerDivider + } = opts + const text = expectedOutput === 'text' + + const { output, status } = spawnSync(cmd, args, spawnSyncOptions) + + const pwdReg = new RegExp(pwd, 'g') + + let out = (!status) + ? output[1].toString('utf8') + : '' + + out = (isWin) + ? windowsPathProcessing(out, text) + : out.replace(pwdReg, '.') + + if (!text) { + out = JSON.parse(out) + } + + if (stripWhiteSpace) { + out = out.replace(whiteSpaceReg, '') + } + + if (text && removeBannerDivider) { + out = out.replace(/-{3,}/g, '') + } + + return out +} + +/** + * Function: windowsPathProcessing + * + * @param {String} output + * @param {Boolean} text=false + * @returns {String} - output with windows specific absolute paths + * replaced with relative paths to the project's directory + * + * Replace all occurrences of the projects absolute path + * with a relative directory path. + * + */ +const windowsPathProcessing = (output, text = false) => { + let jsonPwd = pwd.replace(/\\/g, '\\\\') + + // Replace once more because the json is already escaped + if (!text) { + jsonPwd = jsonPwd.replace(/\\/g, '\\\\') + } + + // match the escaped absolute project's directory + const jsonPwdReg = new RegExp(jsonPwd, 'g') + // replace with a relative path + return output.replace(jsonPwdReg, '.') +} + +/** + * Function: textGetConfigKey + * + * @param {String} out: utf-8 formatted output from + * child process of c8 with --print-config flag. + * @param {String} key: of configuration setting + * to return. + * @returns {String|null}: value of key, if + * found or null. + * + * Get a value of a configuration key from text input. + * + */ +const textGetConfigKey = (out, key) => { + const newLineReturn = (isWin) ? '\r\n' : '\n' + const newLineRegEx = new RegExp(newLineReturn, 'g') + + let value = null + const keyReg = new RegExp(key + ':.+', 'g') + const matches = [...out.matchAll(keyReg)] + if (matches.length > 0 && typeof matches[0][0] === 'string') { + const fileName = matches[0][0].replace(newLineRegEx, '') + .replace(key + ':', '') + .replace(whiteSpaceReg, '') + .replace(/'/g, '') + value = fileName + } + + return value +} + +module.exports = { runc8, textGetConfigKey } From c822613d58db4b7cbb0dd87e8937233cc6cc160f Mon Sep 17 00:00:00 2001 From: Trevor D McKeown Date: Sun, 18 Feb 2024 08:42:38 -0500 Subject: [PATCH 3/3] chore: circleci for matrix builds across win, mac, and linux for node v14 - v20 --- .circleci/config.yml | 124 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..ee52be24 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,124 @@ +--- +# +# This build use extensive use of parameters +# https://circleci.com/docs/reusing-config/#using-the-parameters-declaration +# +# And Conditional Steps +# https://circleci.com/docs/reusing-config/#defining-conditional-steps + +version: 2.1 + +orbs: + node: circleci/node@5.2.0 + +commands: + project-setup: + parameters: + working-dir: + type: string + node-version: + type: string + windows: + type: boolean + default: false + steps: + - checkout: + path: << parameters.working-dir >> + - when: + condition: + equal: [ true, << parameters.windows >> ] + steps: + - run: + name: nvm-install + command: choco install nvm -y + - run: + name: node-install + command: | + Start-Process powershell -verb runAs -Args "-start GeneralProfile" + nvm install << parameters.node-version >> + nvm use << parameters.node-version >> + - run: + name: npm-install + command: npm ci + - when: + condition: + equal: [ false, << parameters.windows >> ] + steps: + - node/install: + node-version: << parameters.node-version >> + install-yarn: false + - node/install-packages: + check-cache: always + pkg-manager: npm + with-cache: false + + lint-test: + steps: + - run: + command: npm run posttest + + unit-test: + steps: + - run: + command: npm run test + + +executors: + linux: # a Linux VM running Ubuntu 20.04 + docker: + - image: cimg/base:2024.01 + working_directory: /home/circleci/project/c8 + macos: # macos executor running Xcode + macos: + xcode: 14.2.0 + working_directory: /Users/distiller/project/c8 + win: + machine: + image: 'windows-server-2019-vs2019:2023.10.1' + resource_class: windows.medium + shell: powershell.exe -ExecutionPolicy Bypass + working_directory: C:\Users\circleci\project\c8 + +jobs: + # Refactor to a command + test: + parameters: + os: + type: string + node-version: + type: string + executor: << parameters.os >> + steps: + - when: + condition: + equal: [ linux, << parameters.os >> ] + steps: + - project-setup: + node-version: << parameters.node-version >> + working-dir: /home/circleci/project/c8 + - when: + condition: + equal: [ win , << parameters.os >> ] + steps: + - project-setup: + node-version: << parameters.node-version >> + working-dir: C:\Users\circleci\project\c8 + windows: true + - when: + condition: + equal: [ macos, << parameters.os >> ] + steps: + - project-setup: + node-version: << parameters.node-version >> + working-dir: /Users/distiller/project/c8 + - lint-test + - unit-test + +workflows: + matrix-test: + jobs: + - test: + matrix: + parameters: + os: [win, linux, macos] + node-version: ["14.21.3", "16.20.2", "18.19.0", "20.11.0"] \ No newline at end of file