diff --git a/config/default.js b/config/default.js new file mode 100644 index 0000000..600d9ac --- /dev/null +++ b/config/default.js @@ -0,0 +1,31 @@ +module.exports = { + + programStore: './recipes', + pluginStore: './bricks', + destPrefix: 'build', + + // path related + dest: null, + program: null, + + // server related + port: 8080, + host: 'localhost', + bsProxy: { + port: 3000, + host: 'localhost' + }, + apiProxy: null, + watch: false, + livereload: false, + https: false, + + // others + hashbit: 7, + lint: false, + offline: false, + registry: null, + showConfig: false, + debuggable: false, + compress: true +} diff --git a/lib/configLoader.js b/lib/configLoader.js index d524f8b..4cccf26 100644 --- a/lib/configLoader.js +++ b/lib/configLoader.js @@ -6,9 +6,10 @@ const _ = require('lodash') const path = require('path') +const fs = require('fs') const logger = require('log4js').getLogger('ConfigLoader') -const defaultConfigPath = './config/default.js' +const frameworkDefaultConfigPath = path.resolve(__dirname, '../config/default.js') module.exports = Object.seal({ run: loadConfig @@ -21,13 +22,15 @@ module.exports = Object.seal({ * @returns {Object} */ function loadConfig(configPath) { - const configPathQueue = [configPath, defaultConfigPath] + const configPathQueue = [configPath, frameworkDefaultConfigPath] logger.debug('the config path queue is: ', configPathQueue) return configPathQueue.reduceRight(function (configObject, _path) { if (_path) { - let targetConfig = require(path.resolve(process.cwd(), _path)) + const resolvedPath = path.resolve(process.cwd(), _path) + + let targetConfig = require(resolvedPath) _.assignIn(configObject, targetConfig) } diff --git a/test-resources/fake-brickyard2/config/default.js b/test-resources/fake-brickyard2/config/default.js deleted file mode 100644 index d47360a..0000000 --- a/test-resources/fake-brickyard2/config/default.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - // path related - output: null, - program: null, - - // server related - port: 8080, - proxyPort: 3000, - host: 'localhost', - proxyHost: 'localhost', - serverAddress: 'localhost', - watch: false, - livereload: false, - protocol: 'http', - - // others - hashbit: 7, - lint: false, - offline: false, - npmRegistry: null, - - /////////////// - // for test - msg: 123 -}