UNPKG

@halospv3/hce.shared-config

Version:

Automate commit message quality, changelogs, and CI/CD releases. Exports a semantic-release shareable configuration deserialized from this package's '.releaserc.yml'. Shared resources for .NET projects are also distributed with this package.

38 lines (34 loc) 933 B
'use strict'; const dotenv = require('dotenv'); const node_process = require('node:process'); /** * Load a .env file from the CWD with the given options (or defaults), returns the new value of process.env * @param dotenvOptions * @param overrides * @returns */ function getEnv(dotenvOptions, overrides) { dotenv.config(dotenvOptions); if (overrides) Object.assign(node_process.env, overrides); return node_process.env; } /** * Get the value from the given env var. If undefined, load .env from CWD and try again or return undefined. * @param envVar * @returns */ function getEnvVarValue(envVar) { let value = node_process.env[envVar]; if (!value) { try { dotenv.config(); } catch (err) { console.error(String(err)); } value = node_process.env[envVar]; } return value; } exports.getEnv = getEnv; exports.getEnvVarValue = getEnvVarValue; //# sourceMappingURL=envUtils.cjs.map