Skip to content

Commit 610105c

Browse files
committed
Cleanup meow use
1 parent 3fd1ab5 commit 610105c

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/cli.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ void (async () => {
6565

6666
// Try to parse the flags, find out if --json is set.
6767
const isJson = (() => {
68-
const cli = meow(``, {
68+
const cli = meow({
6969
argv: process.argv.slice(2),
70+
// Prevent meow from potentially exiting early.
7071
autoHelp: false,
7172
autoVersion: false,
7273
flags: {},

src/flags.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ type RawSpaceSizeFlags = {
2323
let _rawSpaceSizeFlags: RawSpaceSizeFlags | undefined
2424
function getRawSpaceSizeFlags(): RawSpaceSizeFlags {
2525
if (_rawSpaceSizeFlags === undefined) {
26-
const cli = meow(``, {
26+
const cli = meow({
2727
argv: process.argv.slice(2),
28+
// Prevent meow from potentially exiting early.
2829
autoHelp: false,
2930
autoVersion: false,
3031
flags: {

src/utils/meow-with-subcommands.mts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,18 @@ export async function meowWithSubcommands(
167167

168168
// This is basically a dry-run parse of cli args and flags. We use this to
169169
// determine config overrides and expected o mode.
170-
const cli1 = meow(``, {
170+
const cli1 = meow({
171171
argv,
172172
importMeta,
173173
...additionalOptions,
174174
flags,
175-
// Do not strictly check for flags here.
175+
// Ensure we don't check unknown flags.
176176
allowUnknownFlags: true,
177-
booleanDefault: undefined, // We want to detect whether a bool flag is given at all.
178-
// We will emit help when we're ready
179-
// Plus, if we allow this then meow() can just exit here.
177+
// Prevent meow from potentially exiting early.
180178
autoHelp: false,
181179
autoVersion: false,
180+
// We want to detect whether a bool flag is given at all.
181+
booleanDefault: undefined,
182182
})
183183

184184
const orgFlag = String(cli1.flags['org'] || '') || undefined
@@ -402,7 +402,7 @@ ${isRootCommand ? ` $ ${name} scan create --json` : ''}${isRootCommand ? `\
402402
// Do not strictly check for flags here.
403403
allowUnknownFlags: true,
404404
// We will emit help when we're ready.
405-
// Plus, if we allow this then meow() can just exit here.
405+
// Plus, if we allow this then meow may exit here.
406406
autoHelp: false,
407407
autoVersion: false,
408408
// We want to detect whether a bool flag is given at all.
@@ -448,9 +448,11 @@ export function meowOrExit({
448448
// This exits if .printHelp() is called either by meow itself or by us.
449449
const cli = meow({
450450
argv,
451-
autoHelp: false, // meow will exit(0) before printing the banner.
451+
// Prevent meow from potentially exiting early.
452+
autoHelp: false,
452453
autoVersion: false,
453-
booleanDefault: undefined, // We want to detect whether a bool flag is given at all.
454+
// We want to detect whether a bool flag is given at all.
455+
booleanDefault: undefined,
454456
collectUnknownFlags: true,
455457
description: config.description,
456458
flags: config.flags,
@@ -472,6 +474,7 @@ export function meowOrExit({
472474
// meow({
473475
// argv,
474476
// allowUnknownFlags: false,
477+
// // Prevent meow from potentially exiting early.
475478
// autoHelp: false,
476479
// autoVersion: false,
477480
// description: config.description,
@@ -503,6 +506,7 @@ export function meowOrExit({
503506
// As per https://github.com/sindresorhus/meow/issues/178
504507
// Setting `allowUnknownFlags: false` makes it reject camel cased flags.
505508
allowUnknownFlags: Boolean(allowUnknownFlags),
509+
// Prevent meow from potentially exiting early.
506510
autoHelp: false,
507511
autoVersion: false,
508512
description: config.description,

0 commit comments

Comments
 (0)