diff --git a/src/cli/unknown.ts b/src/cli/unknown.ts index 668521e..4406a94 100644 --- a/src/cli/unknown.ts +++ b/src/cli/unknown.ts @@ -1,3 +1,4 @@ +import { ErrorCode } from '../deploy'; import { printHelp } from '../help'; import args from './args'; import { warn } from './messages'; @@ -10,6 +11,8 @@ export const handleUnknownArgs = (): void => { ', ' )} does not exist as a valid command.`; warn(message); + printHelp(ErrorCode.UnknownFlag); + return; } printHelp(); diff --git a/src/deploy.ts b/src/deploy.ts index 45e9b64..93d11f3 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -29,12 +29,13 @@ import { filterFiles, getEnv, loadFilesToRun, zip } from './utils'; export enum ErrorCode { Ok = 0, - NotDirectoryRootPath = 1, - EmptyRootPath = 2, - NotFoundRootPath = 3, - AccountDisabled = 4, - DeployPackageFailed = 5, - DeployRepositoryFailed = 6 + UnknownFlag = 1, + NotDirectoryRootPath = 2, + EmptyRootPath = 3, + NotFoundRootPath = 4, + AccountDisabled = 5, + DeployPackageFailed = 6, + DeployRepositoryFailed = 7 } export const deployPackage = async ( diff --git a/src/help.ts b/src/help.ts index 87b193b..c6da48e 100644 --- a/src/help.ts +++ b/src/help.ts @@ -62,7 +62,7 @@ Examples: For more information, visit: https://github.com/metacall/deploy `; -export const printHelp = (): void => { +export const printHelp = (exitCode: ErrorCode = ErrorCode.Ok): void => { console.log(helpText); - return process.exit(ErrorCode.Ok); + return process.exit(exitCode); };