Skip to content

Commit fa83cb0

Browse files
enh: Add environment variable checks for ContentstackClient
1 parent bdaed1a commit fa83cb0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/sanity-check/utility/ContentstackClient.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import * as contentstack from '../../../lib/contentstack.js'
22
import dotenv from 'dotenv'
33
dotenv.config()
4+
5+
const requiredVars = ['HOST', 'EMAIL', 'PASSWORD', 'ORGANIZATION', 'API_KEY']
6+
const missingVars = requiredVars.filter((key) => !process.env[key])
7+
8+
if (missingVars.length > 0) {
9+
console.error(`\x1b[31mError: Missing environment variables - ${missingVars.join(', ')}`)
10+
process.exit(1)
11+
}
12+
413
function contentstackClient (authtoken = null) {
514
var params = { host: process.env.HOST, defaultHostName: process.env.DEFAULTHOST }
615
if (authtoken) {

0 commit comments

Comments
 (0)