-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (34 loc) · 910 Bytes
/
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
'use strict';
const { resolve } = require('path')
, chalk = require('chalk')
, pkg = require('./package.json')
, debug = require('debug')(`${pkg.name}:boot`);
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 env.NODE_ENV === 'test'; }
,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 || 8080;
}
,get root() {
return __dirname;
}
,package: pkg
,env,
};