Skip to content

Commit

Permalink
feat: add framework default config and remove old default config logic
Browse files Browse the repository at this point in the history
  • Loading branch information
e-cloud committed Aug 3, 2016
1 parent 1b6b3d0 commit 195dd4b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
31 changes: 31 additions & 0 deletions 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
}
9 changes: 6 additions & 3 deletions lib/configLoader.js
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down
25 changes: 0 additions & 25 deletions test-resources/fake-brickyard2/config/default.js

This file was deleted.

0 comments on commit 195dd4b

Please sign in to comment.