Commit f93bb966 by lxyang

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

parent 67d840bc
src/ src/
node_modules/
{ {
"name": "babel-plugin-ry-istanbul", "name": "babel-plugin-ry-istanbul",
"version": "0.0.1-bat", "version": "0.0.3-bat",
"author": "Thai Pangsakulyanont @dtinth", "author": "Thai Pangsakulyanont @dtinth",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"description": "A babel plugin that adds istanbul instrumentation to ES6 code", "description": "A babel plugin that adds istanbul instrumentation to ES6 code",
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
"nyc": "^15.0.0", "nyc": "^15.0.0",
"pmock": "^0.2.3", "pmock": "^0.2.3",
"standard": "^14.3.1", "standard": "^14.3.1",
"pass-diff": "^0.9.0",
"babel-cli": "^6.3.17", "babel-cli": "^6.3.17",
"babel-plugin-istanbul": "^2.0.3", "babel-plugin-istanbul": "^2.0.3",
"babel-preset-es2015": "^6.3.13", "babel-preset-es2015": "^6.3.13",
......
...@@ -108,14 +108,36 @@ export default declare(api => { ...@@ -108,14 +108,36 @@ export default declare(api => {
this.nycConfig = findConfig(this.opts) this.nycConfig = findConfig(this.opts)
const realPath = getRealpath(this.file.opts.filename) const realPath = getRealpath(this.file.opts.filename)
const { instrmenttation } = this.nycConfig // npm引入参数 const { instrmenttation } = this.nycConfig // npm引入参数
const { let IS_PITCHING_PILE_DATA = false
IS_PITCHING_PILE = false, let INCREMENT_DATA = false
INCREMENT = false, let BRANCH_DATA = 'origin/master'
BRANCH = 'origin/master' let processData = {}
} = instrmenttation || {} // 是否全量代码和对比分支 Object.keys(process.env).forEach(item => {
console.log(IS_PITCHING_PILE, INCREMENT, BRANCH, 'IS_PITCHING_PILE, INCREMENT, BRANCH') 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 是否开启增量代码检测) 拿配置到底是全量代码还是增量代码 // instrumenttation (branch: git diff 跟那个分支对比, increment 是否开启增量代码检测) 拿配置到底是全量代码还是增量代码
if (!IS_PITCHING_PILE) { if (!IS_PITCHING_PILE_DATA) {
return return
} }
// const changeList = [] // const changeList = []
...@@ -126,8 +148,8 @@ export default declare(api => { ...@@ -126,8 +148,8 @@ export default declare(api => {
// return realPath.indexOf(item.to) > -1 // return realPath.indexOf(item.to) > -1
// }) // })
// 后面解开 // 后面解开
if (INCREMENT && BRANCH) { if (INCREMENT_DATA && BRANCH_DATA) {
const gitDiffCode = execSync(`git diff ${BRANCH}`) const gitDiffCode = execSync(`git diff ${BRANCH_DATA}`)
const diffData = parseDiffData(gitDiffCode.toString()) const diffData = parseDiffData(gitDiffCode.toString())
diffScreen = diffData.find(item => { diffScreen = diffData.find(item => {
return realPath.indexOf(item.to) > -1 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