Skip to content

Commit

Permalink
Merge pull request #13 from DamianOsipiuk/fix-crash-when-no-config-file
Browse files Browse the repository at this point in the history
Fix error when no testrail config file was found.
  • Loading branch information
Damian Osipiuk authored Sep 1, 2020
2 parents b6e3a33 + 698c5e5 commit 0b8ac2c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testcafe-reporter-testrail",
"version": "0.6.1",
"version": "0.6.2",
"description": "Testcafe reporter plugin that automatically publishes test run details to the TestRail system.",
"main": "lib/index.js",
"files": [
Expand Down
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ const Status = {
};

const loadJSON = (file: string) => {
const data = fs.readFileSync(file, { encoding: "utf8" });
try {
const data = fs.readFileSync(file, { encoding: "utf8" });

if (data) {
return JSON.parse(data);
}
} catch {}

if (data) {
return JSON.parse(data);
}
return {};
};

Expand Down

0 comments on commit 0b8ac2c

Please sign in to comment.