Skip to content

Commit

Permalink
Catch missing file failure and continue
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox authored Dec 4, 2019
1 parent 701ecad commit b487c50
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
var fs = require('fs');

function readExampleFile(name, raw) {
var text = fs.readFileSync(name, 'UTF8');

if (raw) {
return text;
} else {
return JSON.parse(text);
let text = null;
try {
text = fs.readFileSync(name, 'UTF8');
} catch (e) {
/* eslint-disable no-console */
console.error(JSON.stringify(e));
}
return raw ? text : JSON.parse(text);
}

function delay(ms) {
Expand Down

0 comments on commit b487c50

Please sign in to comment.