( directory: string, possibleNames: string[] )
| 5 | import { renderApiKey } from "./renderApiKey"; |
| 6 | |
| 7 | export async function getEnvFilename( |
| 8 | directory: string, |
| 9 | possibleNames: string[] |
| 10 | ): Promise<string | undefined> { |
| 11 | if (possibleNames.length === 0) { |
| 12 | throw new Error("No possible names provided"); |
| 13 | } |
| 14 | |
| 15 | for (let index = 0; index < possibleNames.length; index++) { |
| 16 | const name = possibleNames[index]; |
| 17 | if (!name) continue; |
| 18 | |
| 19 | const path = pathModule.join(directory, name); |
| 20 | const envFileExists = await pathExists(path); |
| 21 | if (envFileExists) { |
| 22 | return name; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | return undefined; |
| 27 | } |
| 28 | |
| 29 | export async function setApiKeyEnvironmentVariable(dir: string, fileName: string, apiKey: string) { |
| 30 | await setEnvironmentVariable(dir, fileName, "TRIGGER_API_KEY", apiKey, true, renderApiKey); |
no test coverage detected
searching dependent graphs…