-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle the invalid command resulting in infinite loop
- Loading branch information
1 parent
8322436
commit c9a1cfb
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [ | ||
'--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])) { | ||
await printError(`Invalid command. Please use one of the following commands: ${availableCommands.join(', ')}`); | ||
// Exit the process with a status code of 1 (indicating an error) | ||
process.exit(1); | ||
} | ||
})(); | ||
|
||
export { run } from '@oclif/command'; |