-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
57 lines (54 loc) · 1.66 KB
/
config.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
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
var chalk = require('chalk');
// Based on http://blog.codehatcher.com/node-js-alternate-config-file
module.exports = (function () {
var pkg = require('./package.json'),
YAML = require('yamljs'),
argv = require('yargs').argv,
dataDir = argv.dataDir || 'data',
siteConfig = YAML.load(dataDir + '/site.yaml'),
characterConfig = YAML.load(dataDir + '/characters.yaml'),
mediaConfig = {},
error = chalk.bold.red,
warning = chalk.yellow,
info = chalk.cyan,
debug = chalk.blue,
success = chalk.bold;
switch (process.env.NODE_ENV) {
case null:
case undefined:
case 'local':
return {
env: 'local',
site: siteConfig,
character: characterConfig,
media: mediaConfig,
dataDir: dataDir,
pkg: pkg,
error: error,
warning: warning,
info: info,
debug: debug,
success: success,
gtm: 'GTM-N2JHDQ'
};
case 'prod':
case 'production':
return {
env: 'prod',
site: siteConfig,
character: characterConfig,
media: mediaConfig,
dataDir: dataDir,
pkg: pkg,
error: error,
warning: warning,
info: info,
debug: debug,
success: success,
gtm: 'GTM-TK3LN4'
};
default:
throw new Error('Environment Not Recognized');
}
}());