-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.js
45 lines (41 loc) · 1.09 KB
/
index.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict'
const {resolve} = require('path')
, chalk = require('chalk')
, pkg = require('./package.json')
, debug = require('debug')(`${pkg.name}:boot`)
// This will load a secrets file from
//
// ~/.your_app_name.env.js
// or ~/.your_app_name.env.json
//
// and add it to the environment.
// Note that this needs to be in your home directory, not the project's root directory
const env = process.env
, secretsFile = resolve(require('homedir')(), `.${pkg.name}.env`)
try {
Object.assign(env, require(secretsFile))
} catch (error) {
debug('%s: %s', secretsFile, error.message)
debug('%s: env file not found or invalid, moving on', secretsFile)
}
module.exports = {
get name() { return pkg.name },
get isTesting() { return !!global.it },
get isProduction() {
return env.NODE_ENV === 'production'
},
get isDevelopment() {
return env.NODE_ENV === 'development'
},
get baseUrl() {
return env.BASE_URL || `http://localhost:${module.exports.port}`
},
get port() {
return env.PORT || 1337
},
get root() {
return __dirname
},
package: pkg,
env,
}