-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathyworkflow.js
38 lines (28 loc) · 1.07 KB
/
yworkflow.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
'use strict'
const _ = require('lodash');
const path = require('path');
const fs = require('fs');
const chalk = require('chalk');
//获得Yworkflow项目根路径
const rootPath = path.resolve('.');
const gutil = require('gulp-util');
/**
* 加载启动Yworkflow本地Server的核心配置
* 根据配置读取业务代码
*/
module.exports.getConfig = function() {
let configFile = gutil.env.path ? gutil.env.path : '../.yconfig';
let options = require('./ywork.default');
// 首先检查Yworkflow外层文件夹是否存在 .ywork 配置文件
// 如果存在,则使用外部配置
if (fs.existsSync(configFile)) {
let projectConfig = require(path.resolve(configFile))
options.absPath = path.resolve(configFile).substring(0,path.resolve(configFile).indexOf(path.basename(path.resolve(configFile))))
options = _.merge(options,projectConfig)
} else {
console.log(chalk.red('[没有找到配置文件,请检查是否在项目路径]'));
console.log(chalk.green('文件:' + path.resolve(configFile) + ' 不存在'));
return false;
}
return options;
}