Skip to content

Commit

Permalink
add version fallback message
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Jan 28, 2024
1 parent 7876197 commit 605aaf7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const buildOptions = (helpMessage: string, options: Options<AnyFlags>): P
input: 'string',
description: pkg.description ?? false,
help: helpMessage,
version: pkg.version ?? '', // TODO: maybe say "No version found"?
version: pkg.version || 'No version found', // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
autoHelp: true,
autoVersion: true,
booleanDefault: false,
Expand Down
5 changes: 5 additions & 0 deletions test/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ test('manual showVersion', async t => {
const {stdout} = await spawnFixture(fixture, ['--show-version']);
t.is(stdout, '1.0.0');
});

test('no version fallback message', async t => {
const {stdout} = await spawnFixture('with-package-json/fixture.ts', ['--version']);
t.is(stdout, 'No version found');
});

0 comments on commit 605aaf7

Please sign in to comment.