Skip to content

Commit

Permalink
Add ability to specific DOTENV_API_URL in .env.vault as a configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
motdotla committed Jun 17, 2023
1 parent 59fedcc commit b9420f0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {existsSync, readFileSync} from 'fs'

export class Vars {
get apiUrl(): string {
return process.env.DOTENV_API_URL || 'https://vault.dotenv.org'
// read from process.env first, then .env.vault configuration file first, then default
return process.env.DOTENV_API_URL || this.vaultParsed.DOTENV_API_URL || 'https://vault.dotenv.org'
}

get vaultFilename(): string {
Expand All @@ -23,8 +24,12 @@ export class Vars {
return 'DOTENV_VAULT'
}

get vaultParsed(): Record<string, any> {
return dotenv.configDotenv({path: vars.vaultFilename}).parsed || {}
}

get vaultValue(): string {
return (dotenv.configDotenv({path: vars.vaultFilename}).parsed || {})[vars.vaultKey]
return this.vaultParsed[vars.vaultKey]
}

get existingEnvVault(): boolean {
Expand Down

0 comments on commit b9420f0

Please sign in to comment.