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

Fix --version #2501

Closed
Closed
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
4 changes: 3 additions & 1 deletion lib/helpers/cli.js
Expand Up @@ -5,12 +5,14 @@ import { globbySync } from 'globby';
import isGlob from 'is-glob';
import micromatch from 'micromatch';
import fs from 'node:fs';
import { createRequire } from 'node:module';
import path from 'node:path';
import yargs from 'yargs';

import camelize from './camelize.js';

const STDIN = '/dev/stdin';
const require = createRequire(import.meta.url);

class NoMatchingFilesError extends Error {
constructor(...params) {
Expand Down Expand Up @@ -130,7 +132,7 @@ export function parseArgv(_argv) {
.usage('$0 [options] [files..]')
.options(specifiedOptions)
.help()
.version();
.version(require('../../package.json').version);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to indicate there is a yargs bug in retrieving the version, perhaps when ESM is present? Is there an active yargs issue for this? I'd prefer it was fixed there. If we are going to add a workaround, we would at least need to comment to explain why it's needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're suspicion is correct!: yargs/yargs#2122

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified yargs/yargs#2123 fixes the issue, so hopefully that will go in soon!


parser.parserConfiguration({
'greedy-arrays': false,
Expand Down