Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly configure ava --version value #2961

Merged
merged 1 commit into from Feb 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/cli.js
Expand Up @@ -21,6 +21,7 @@ import {splitPatternAndLineNumbers} from './line-numbers.js';
import {loadConfig} from './load-config.js';
import normalizeModuleTypes from './module-types.js';
import normalizeNodeArguments from './node-arguments.js';
import pkg from './pkg.cjs';
import providerManager from './provider-manager.js';
import DefaultReporter from './reporters/default.js';
import TapReporter from './reporters/tap.js';
Expand Down Expand Up @@ -102,7 +103,7 @@ export default async function loadCli() { // eslint-disable-line complexity
let conf;
let confError;
try {
const {argv: {config: configFile}} = yargs(hideBin(process.argv)).help(false);
const {argv: {config: configFile}} = yargs(hideBin(process.argv)).help(false).version(false);
conf = await loadConfig({configFile});
if (conf.configFile && path.basename(conf.configFile) !== path.relative(conf.projectDir, conf.configFile)) {
console.log(chalk.magenta(` ${figures.warning} Using configuration from ${conf.configFile}`));
Expand Down Expand Up @@ -132,6 +133,7 @@ export default async function loadCli() { // eslint-disable-line complexity

let resetCache = false;
const {argv} = yargs(hideBin(process.argv))
.version(pkg.version)
.parserConfiguration({
'boolean-negation': true,
'camel-case-expansion': false,
Expand Down Expand Up @@ -319,16 +321,16 @@ export default async function loadCli() { // eslint-disable-line complexity
exit('’sources’ has been removed. Use ’ignoredByWatcher’ to provide glob patterns of files that the watcher should ignore.');
}

let pkg;
let projectPackageObject;
try {
pkg = JSON.parse(fs.readFileSync(path.resolve(projectDir, 'package.json')));
projectPackageObject = JSON.parse(fs.readFileSync(path.resolve(projectDir, 'package.json')));
} catch (error) {
if (error.code !== 'ENOENT') {
throw error;
}
}

const {type: defaultModuleType = 'commonjs'} = pkg || {};
const {type: defaultModuleType = 'commonjs'} = projectPackageObject || {};

const providers = [];
if (Reflect.has(conf, 'typescript')) {
Expand Down