@lipemat/js-boilerplate 8.6.1 → 8.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/helpers/config.js +12 -9
- package/package.json +1 -1
package/helpers/config.js
CHANGED
|
@@ -53,14 +53,15 @@ function hasLocalOverride( fileName, inWorkingDirectory = false ) {
|
|
|
53
53
|
* }
|
|
54
54
|
* ```
|
|
55
55
|
*
|
|
56
|
-
* @param {string}
|
|
56
|
+
* @param {string} fileName
|
|
57
57
|
*
|
|
58
58
|
* @return {Object}
|
|
59
59
|
*/
|
|
60
|
-
function getConfig(
|
|
61
|
-
let config =
|
|
60
|
+
function getConfig( fileName ) {
|
|
61
|
+
let config = require( '../config/' + fileName );
|
|
62
|
+
config = {...config, ...getExtensionsConfig( fileName, config )};
|
|
62
63
|
try {
|
|
63
|
-
const localConfig = require( path.resolve( packageConfig.packageDirectory + '/config',
|
|
64
|
+
const localConfig = require( path.resolve( packageConfig.packageDirectory + '/config', fileName ) );
|
|
64
65
|
if ( 'function' === typeof localConfig ) {
|
|
65
66
|
config = {...config, ...localConfig( config )};
|
|
66
67
|
} else {
|
|
@@ -75,19 +76,21 @@ function getConfig( $fileName ) {
|
|
|
75
76
|
* Get a config from any existing extension's /config directories
|
|
76
77
|
* merged into one.
|
|
77
78
|
*
|
|
78
|
-
* @
|
|
79
|
+
* @param {string} fileName
|
|
80
|
+
* @param {Object} defaultConfig - Default config from this package.
|
|
81
|
+
* Used for passing to an extension callback.
|
|
79
82
|
*
|
|
80
|
-
* @
|
|
83
|
+
* @see getConfig
|
|
81
84
|
*
|
|
82
85
|
* @return {Object}
|
|
83
86
|
*/
|
|
84
|
-
function getExtensionsConfig(
|
|
87
|
+
function getExtensionsConfig( fileName, defaultConfig ) {
|
|
85
88
|
let config = {};
|
|
86
89
|
extensions.forEach( extension => {
|
|
87
90
|
try {
|
|
88
|
-
const extensionConfig = require( extension + '/config/' +
|
|
91
|
+
const extensionConfig = require( extension + '/config/' + fileName );
|
|
89
92
|
if ( 'function' === typeof extensionConfig ) {
|
|
90
|
-
config = {...config, ...extensionConfig( config )};
|
|
93
|
+
config = {...config, ...extensionConfig( {...defaultConfig, ...config} )};
|
|
91
94
|
} else {
|
|
92
95
|
config = {...config, ...extensionConfig};
|
|
93
96
|
}
|