-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathenv.js
31 lines (26 loc) · 847 Bytes
/
env.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require('fs');
const path = require('path');
const debug = require('debug');
const dotenv = require('dotenv');
const lodash = require('lodash');
// Load extra env file on demand
// e.g. `npm run dev production` -> `.env.production`
const extraEnv = process.env.EXTRA_ENV || lodash.last(process.argv);
const extraEnvPath = path.join(__dirname, `.env.${extraEnv}`);
if (fs.existsSync(extraEnvPath)) {
dotenv.config({ path: extraEnvPath });
}
dotenv.config();
debug.enable(process.env.DEBUG);
const defaults = {
NODE_ENV: 'development',
API_KEY: '09u624Pc9F47zoGLlkg1TBSbOl2ydSAq',
API_URL: 'https://api-staging.opencollective.com',
OC_APPLICATION: 'tools',
OC_ENV: process.env.NODE_ENV || 'development',
};
for (const key in defaults) {
if (process.env[key] === undefined) {
process.env[key] = defaults[key];
}
}