Commit f93bb966 by lxyang

feat:优化插桩启动服务时报错的问题

parent 67d840bc
{
"name": "babel-plugin-ry-istanbul",
"version": "0.0.1-bat",
"version": "0.0.3-bat",
"author": "Thai Pangsakulyanont @dtinth",
"license": "BSD-3-Clause",
"description": "A babel plugin that adds istanbul instrumentation to ES6 code",
......@@ -40,7 +40,6 @@
"nyc": "^15.0.0",
"pmock": "^0.2.3",
"standard": "^14.3.1",
"pass-diff": "^0.9.0",
"babel-cli": "^6.3.17",
"babel-plugin-istanbul": "^2.0.3",
"babel-preset-es2015": "^6.3.13",
......
......@@ -108,14 +108,36 @@ export default declare(api => {
this.nycConfig = findConfig(this.opts)
const realPath = getRealpath(this.file.opts.filename)
const { instrmenttation } = this.nycConfig // npm引入参数
const {
IS_PITCHING_PILE = false,
INCREMENT = false,
BRANCH = 'origin/master'
} = instrmenttation || {} // 是否全量代码和对比分支
console.log(IS_PITCHING_PILE, INCREMENT, BRANCH, 'IS_PITCHING_PILE, INCREMENT, BRANCH')
let IS_PITCHING_PILE_DATA = false
let INCREMENT_DATA = false
let BRANCH_DATA = 'origin/master'
let processData = {}
Object.keys(process.env).forEach(item => {
let isItem =
typeof process.env[item] === 'string' ? Boolean(process.env[item]) : process.env[item]
if (item.indexOf('INCREMENT')) {
processData.INCREMENT = isItem
}
if (item.indexOf('IS_PITCHING_PILE')) {
processData.IS_PITCHING_PILE = isItem
}
if (item.indexOf('PROSRC')) {
processData.PROSRC = process.env[item]
}
// Object.keys(processData).length
})
// 全局变量优先
if (Object.keys(processData).length) {
BRANCH_DATA = processData.BRANCH
INCREMENT_DATA = processData.INCREMENT
IS_PITCHING_PILE_DATA = processData.IS_PITCHING_PILE
} else if (Object.keys(instrmenttation).length) {
BRANCH_DATA = instrmenttation.BRANCH
INCREMENT_DATA = instrmenttation.INCREMENT
IS_PITCHING_PILE_DATA = instrmenttation.IS_PITCHING_PILE
}
// instrumenttation (branch: git diff 跟那个分支对比, increment 是否开启增量代码检测) 拿配置到底是全量代码还是增量代码
if (!IS_PITCHING_PILE) {
if (!IS_PITCHING_PILE_DATA) {
return
}
// const changeList = []
......@@ -126,8 +148,8 @@ export default declare(api => {
// return realPath.indexOf(item.to) > -1
// })
// 后面解开
if (INCREMENT && BRANCH) {
const gitDiffCode = execSync(`git diff ${BRANCH}`)
if (INCREMENT_DATA && BRANCH_DATA) {
const gitDiffCode = execSync(`git diff ${BRANCH_DATA}`)
const diffData = parseDiffData(gitDiffCode.toString())
diffScreen = diffData.find(item => {
return realPath.indexOf(item.to) > -1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment