|
1 | 1 | import * as fs from 'fs'
|
2 | 2 | import { URL } from 'url'
|
3 | 3 | import Bottleneck from 'bottleneck'
|
4 |
| -import dotenv, { DotenvParseOptions, DotenvParseOutput } from 'dotenv' |
| 4 | +import dotenv, { DotenvParseOptions } from 'dotenv' |
5 | 5 | import { ManagedIdentityCredential, ClientSecretCredential } from '@azure/identity'
|
6 | 6 | import { SecretClient } from '@azure/keyvault-secrets'
|
7 | 7 | import { AppConfigurationClient, ConfigurationSetting } from '@azure/app-configuration'
|
@@ -60,8 +60,8 @@ export default class DotenvAzure {
|
60 | 60 | async config(options: DotenvAzureConfigOptions = {}): Promise<DotenvAzureConfigOutput> {
|
61 | 61 | const { safe = false } = options
|
62 | 62 | const dotenvResult = dotenv.config(options)
|
63 |
| - |
64 |
| - const azureVars = await this.loadFromAzure(dotenvResult.parsed) |
| 63 | + const vars:Record<string, string | undefined> = {...(dotenvResult.parsed || {}), ...process.env} |
| 64 | + const azureVars = await this.loadFromAzure(vars) |
65 | 65 | const joinedVars = { ...azureVars, ...dotenvResult.parsed }
|
66 | 66 |
|
67 | 67 | populateProcessEnv(azureVars)
|
@@ -96,7 +96,8 @@ export default class DotenvAzure {
|
96 | 96 | * @param dotenvVars - dotenv parse() output containing azure credentials variables
|
97 | 97 | * @returns an object with keys and values
|
98 | 98 | */
|
99 |
| - async loadFromAzure(dotenvVars?: DotenvParseOutput): Promise<VariablesObject> { |
| 99 | + async loadFromAzure(dotenvVars?: Record<string, string | undefined>): Promise<VariablesObject> { |
| 100 | + // const vars = {...dotenvVars, ...process.env} |
100 | 101 | const credentials = this.getAzureCredentials(dotenvVars)
|
101 | 102 | const appConfigClient = new AppConfigurationClient(credentials.connectionString)
|
102 | 103 | const labels = dotenvVars?.AZURE_APP_CONFIG_LABELS || ''
|
@@ -201,10 +202,10 @@ export default class DotenvAzure {
|
201 | 202 | )
|
202 | 203 | }
|
203 | 204 |
|
204 |
| - private getAzureCredentials(dotenvVars: DotenvParseOutput = {}): AzureCredentials { |
| 205 | + private getAzureCredentials(dotenvVars: Record<string, string | undefined> = {}): AzureCredentials { |
205 | 206 | const vars = { ...dotenvVars, ...process.env }
|
206 | 207 | const connectionString = this.connectionString || vars.AZURE_APP_CONFIG_CONNECTION_STRING
|
207 |
| - |
| 208 | + |
208 | 209 | if (!connectionString) {
|
209 | 210 | throw new MissingAppConfigCredentialsError()
|
210 | 211 | }
|
|
0 commit comments