-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtruffle.js
46 lines (40 loc) · 1.08 KB
/
truffle.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
const fs = require('fs')
const { merge } = require('lodash')
const configDefaults = require('./truffle.js.default')
/**
* Reading of config directory
* @param {String} configSection config section/dir name
* @return {Array}
*/
const readConfigDir = configSection => (
fs.readdirSync(`./config/${configSection}`)
.filter ( file => /\.js/.test(file) )
.map ( file => file.replace(/\.js$/i, '') )
)
/**
* Building part of config
* @param {String} configSection config section/dir name
* @param {Object} configSectionDefaults config section defaults
* @return {Object}
*/
const buildConfigPart = (configSection, configSectionDefaults) => (
readConfigDir(configSection).reduce(
(configPart, key) => {
configPart[configSection][key] = merge(
{},
configSectionDefaults,
require(`./config/${configSection}/${key}`)
)
return configPart
},
{
[configSection]: {}
}
)
)
const configAssigned = merge(
{},
configDefaults,
buildConfigPart('networks', configDefaults.rpc)
)
module.exports = configAssigned