Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
// This script checks if the command-line argument provided is one of the available commands.
// If the command is not recognized, it prints an error message and exits the process.
import { printError } from '../util/io';

(async () => {
const availableCommands = [

Check warning on line 6 in src/commands/index.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/index.ts#L5-L6

Added lines #L5 - L6 were not covered by tests
'--help',
'make-publish',
'make',
'migrate-latest',
'migrate-list',
'migrate-rollback',
'prune',
'synchronize',
'--version'
];

// Check if there are at least 3 arguments (node, script, command)
// and if the command is not in the list of available commands
if (process.argv.length >= 3 && !availableCommands.includes(process.argv[2])) {
Comment on lines +19 to +20
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

[nitpick] Destructure process.argv (e.g., const [, , command] = process.argv) for improved readability when extracting the command argument.

Suggested change
// and if the command is not in the list of available commands
if (process.argv.length >= 3 && !availableCommands.includes(process.argv[2])) {
const [, , command] = process.argv;
// and if the command is not in the list of available commands
if (process.argv.length >= 3 && !availableCommands.includes(command)) {

Copilot uses AI. Check for mistakes.

await printError(`Invalid command. Please use one of the following commands: ${availableCommands.join(', ')}`);

Check warning on line 21 in src/commands/index.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/index.ts#L21

Added line #L21 was not covered by tests
// Exit the process with a status code of 1 (indicating an error)
process.exit(1);

Check warning on line 23 in src/commands/index.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/index.ts#L23

Added line #L23 was not covered by tests
}
})();

export { run } from '@oclif/command';
Loading