-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4613c30
commit 1d8ee3b
Showing
3 changed files
with
20 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "babel-plugin-canyon", | ||
"version": "1.8.86", | ||
"version": "1.8.87", | ||
"description": "A Babel plugin cooperates with istanbul to report the coverage", | ||
"author": "Allen Zhang <[email protected]>", | ||
"license": "MIT", | ||
|
35 changes: 18 additions & 17 deletions
35
plugins/babel-plugin-canyon/src/helpers/generate-initial-coverage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
// import fs from 'fs'; | ||
// import path from 'path' | ||
import fs from 'fs'; | ||
import path from 'path' | ||
import {extractCoverageData} from "./extract-coverage-data"; | ||
|
||
|
||
export const generateInitialCoverage = (paramsPath) => { | ||
const initialCoverageDataForTheCurrentFile = extractCoverageData(paramsPath) | ||
// const filePath = './.canyon_output/coverage-final.json'; | ||
// const dir = path.dirname(filePath); | ||
// if (!fs.existsSync(dir)) { | ||
// fs.mkdirSync(dir, {recursive: true}); | ||
// } | ||
// // 防止返回的数据为空 | ||
// if (initialCoverageDataForTheCurrentFile && initialCoverageDataForTheCurrentFile.path) { | ||
// fs.writeFileSync(`./.canyon_output/coverage-${Math.random()}.json`, JSON.stringify({ | ||
// [initialCoverageDataForTheCurrentFile.path]: initialCoverageDataForTheCurrentFile | ||
// }, null, 2), 'utf-8'); | ||
// } | ||
return initialCoverageDataForTheCurrentFile; | ||
export const generateInitialCoverage = (paramsPath,writeCovLocal) => { | ||
const initialCoverageDataForTheCurrentFile = extractCoverageData(paramsPath) | ||
if (writeCovLocal){ | ||
const filePath = './.canyon_output/coverage-final.json'; | ||
const dir = path.dirname(filePath); | ||
if (!fs.existsSync(dir)) { | ||
fs.mkdirSync(dir, {recursive: true}); | ||
} | ||
// 防止返回的数据为空 | ||
if (initialCoverageDataForTheCurrentFile && initialCoverageDataForTheCurrentFile.path) { | ||
fs.writeFileSync(`./.canyon_output/coverage-map-${Math.random()}.json`, JSON.stringify({ | ||
[initialCoverageDataForTheCurrentFile.path]: initialCoverageDataForTheCurrentFile | ||
}, null, 2), 'utf-8'); | ||
} | ||
} | ||
return initialCoverageDataForTheCurrentFile; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters