Skip to content

Commit

Permalink
feat: warn instead of throw on exception (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Sep 16, 2018
1 parent 522720e commit a8620d4
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 12 deletions.
26 changes: 17 additions & 9 deletions lib/report.js
Expand Up @@ -60,11 +60,15 @@ class Report {
})

Object.keys(mergedResults).forEach((url) => {
const result = mergedResults[url]
const path = resolve(this.resolve, result.url)
const script = v8toIstanbul(path)
script.applyCoverage(result.functions)
map.merge(script.toIstanbul())
try {
const result = mergedResults[url]
const path = resolve(this.resolve, result.url)
const script = v8toIstanbul(path)
script.applyCoverage(result.functions)
map.merge(script.toIstanbul())
} catch (err) {
console.warn(`file: ${url} error: ${err.stack}`)
}
})

return map
Expand All @@ -73,10 +77,14 @@ class Report {
const files = readdirSync(this.tempDirectory)

return files.map((f) => {
return JSON.parse(readFileSync(
resolve(this.tempDirectory, f),
'utf8'
))
try {
return JSON.parse(readFileSync(
resolve(this.tempDirectory, f),
'utf8'
))
} catch (err) {
console.warn(`${err.stack}`)
}
})
}
}
Expand Down
86 changes: 86 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions test/integration.js.snap
Expand Up @@ -8,12 +8,12 @@ second
--------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
--------------------|----------|----------|----------|----------|-------------------|
All files | 94.12 | 70.59 | 0 | 94.12 | |
All files | 92.5 | 69.23 | 0 | 92.5 | |
bin | 83.72 | 57.14 | 100 | 83.72 | |
c8.js | 83.72 | 57.14 | 100 | 83.72 |... 22,40,41,42,43 |
lib | 96.41 | 65.38 | 100 | 96.41 | |
lib | 93.71 | 62.96 | 100 | 93.71 | |
parse-args.js | 97.47 | 44.44 | 100 | 97.47 | 55,56 |
report.js | 95.45 | 76.47 | 100 | 95.45 | 51,52,53,54 |
report.js | 90.63 | 72.22 | 100 | 90.63 |... 70,71,85,86,87 |
test/fixtures | 95.16 | 83.33 | 0 | 95.16 | |
async.js | 100 | 100 | 100 | 100 | |
multiple-spawn.js | 100 | 100 | 100 | 100 | |
Expand Down

0 comments on commit a8620d4

Please sign in to comment.