npm install merge.env
or
yarn add merge.env
const args = {
required, // the .env.sample file with keys requirements
defaults, // the .env.default file with default values
current, // the content of the current .env file
};
// Async version, a classic promise using resove / reject
mergeEnv(args)
.then(console.info)
.catch(console.warn);
// Async alternative version, always resolve to [error, result]
// error can either be null or instance of Error
// result can either be undefined or an object...
// ...you can check for error instead of checking result
const [error, mergedEnv] = await mergeEnv(args);
or
const [error, mergedEnv] = mergeEnvSync(args); // Sync version