Skip to content

dx 2230 handle env variables #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 8, 2025
Next Next commit
enh: Add environment variable checks for ContentstackClient
  • Loading branch information
harshithad0703 committed Apr 7, 2025
commit fa83cb014725d7a456a5b153de107a5df2f7d83d
9 changes: 9 additions & 0 deletions test/sanity-check/utility/ContentstackClient.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import * as contentstack from '../../../lib/contentstack.js'
import dotenv from 'dotenv'
dotenv.config()

const requiredVars = ['HOST', 'EMAIL', 'PASSWORD', 'ORGANIZATION', 'API_KEY']
const missingVars = requiredVars.filter((key) => !process.env[key])

if (missingVars.length > 0) {
console.error(`\x1b[31mError: Missing environment variables - ${missingVars.join(', ')}`)
process.exit(1)
}

function contentstackClient (authtoken = null) {
var params = { host: process.env.HOST, defaultHostName: process.env.DEFAULTHOST }
if (authtoken) {
Expand Down