Skip to content
This repository was archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Ensure only JSON is used for demo configuration (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeChampion authored May 18, 2017
1 parent 7a172e7 commit 7d06aea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/tasks/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ function buildHtml(gulp, buildConfig) {
if (typeof buildConfig.demo.data === 'string') {
const dataPath = path.join(buildConfig.cwd, '/' + buildConfig.demo.data);
if (fs.existsSync(dataPath)) {
const fileData = require(dataPath);
let fileData;
try {
fileData = JSON.parse(fs.readFileSync(dataPath));
} catch (error) {
throw new Error(`Demo data file is not valid JSON ${dataPath}`);
}
if (typeof fileData === 'function') {
data = fileData();
} else {
Expand Down

0 comments on commit 7d06aea

Please sign in to comment.