Skip to content

Commit a6e21ee

Browse files
author
Pelle Wessman
committed
Have CLI remember API key for its full duration
1 parent 094c57e commit a6e21ee

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/utils/sdk.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ import prompts from 'prompts'
99
import { AuthError } from './errors.js'
1010

1111
/**
12-
* @returns {Promise<import('@socketsecurity/sdk').SocketSdk>}
12+
* The API key should be stored globally for the duration of the CLI execution
13+
*
14+
* @type {string | undefined}
1315
*/
16+
let apiKey
17+
18+
/** @returns {Promise<import('@socketsecurity/sdk').SocketSdk>} */
1419
export async function setupSdk () {
15-
let apiKey = process.env['SOCKET_SECURITY_API_KEY']
20+
if (!apiKey) {
21+
apiKey = process.env['SOCKET_SECURITY_API_KEY']
22+
}
1623

1724
if (!apiKey && isInteractive()) {
1825
const input = await prompts({

0 commit comments

Comments
 (0)