From c2ae98170c65a272b869291bc44def788236488b Mon Sep 17 00:00:00 2001 From: di-sukharev Date: Sat, 11 Mar 2023 00:19:29 +0800 Subject: [PATCH] * refactor(api.ts): move apiKey initialization to the top of the file * feat(api.ts): add check for process arguments to avoid intro message if 'config set' command is used --- src/api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api.ts b/src/api.ts index 10e14f5..e3da590 100644 --- a/src/api.ts +++ b/src/api.ts @@ -11,7 +11,9 @@ const config = getConfig(); let apiKey = config?.OPENAI_API_KEY; -if (!apiKey) { +const [command, mode] = process.argv.slice(2); + +if (!apiKey && command !== 'config' && mode !== 'set') { intro('opencommit'); outro( @@ -20,6 +22,8 @@ if (!apiKey) { outro( 'For help Look into README https://github.com/di-sukharev/opencommit#setup' ); + + process.exit(1); } // if (!apiKey) {