UNPKG

bm_scaffold_async_router

Version:

本木前端脚手架-异步路由版

54 lines (45 loc) 1.48 kB
/** * @Author: songqi * @Date: 2016-07-15 * @Email: songqi@benmu-health.com * @Last modified by: songqi * @Last modified time: 2017-02-15 */ var fs = require('fs'), _ = require('lodash'), path = require('path'); var CONFIG = null; function readAllConfig() { var configPath = path.join(process.cwd(), './config.js'), erosDevPath = path.join(process.cwd(), './dev.json'), erosConfigPath = path.resolve(process.cwd(), '../config.json'); // 兼容weex-eros 如果上一层有 config.json 本层有dev文件 判定为weex-eros 有点low if (fs.existsSync(erosConfigPath) && fs.existsSync(erosDevPath)) { var erosDev = JSON.parse(fs.readFileSync(erosDevPath)), erosConfig = JSON.parse(fs.readFileSync(erosConfigPath)); CONFIG = _.assign({ weex: true, appName: erosConfig.appName, //三端统一appName zipFolder: erosConfig.zipFolder.server, //三端统一appName localZipFolder: erosConfig.zipFolder, version: erosConfig.version, framework: '// { "framework": "Vue" }\n', }, erosDev) return; } // 否则只读取项目中的js文件 if (fs.existsSync(configPath)) { CONFIG = require(configPath); } } function get(key) { if (CONFIG && CONFIG[key]) { return _.cloneDeep(CONFIG[key]); } else { return false; } } readAllConfig(); module.exports = { get: get }