Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2118 from macor161/truffle-empty-artifact-error
Browse files Browse the repository at this point in the history
Invalid artifacts error
  • Loading branch information
eggplantzzz committed Jun 27, 2019
2 parents af801fd + e804531 commit c7aa546
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/truffle-compile/profiler.js
Expand Up @@ -71,26 +71,33 @@ module.exports = {
"utf8",
(err, body) => {
if (err) return finished(err);
finished(null, body);
finished(null, { file: buildFile, body });
}
);
},
(err, jsonData) => {
if (err) return c(err);

try {
for (let i = 0; i < jsonData.length; i++) {
const data = JSON.parse(jsonData[i]);
for (let i = 0; i < jsonData.length; i++) {
try {
const data = JSON.parse(jsonData[i].body);

// In case there are artifacts from other source locations.
if (sourceFilesArtifacts[data.sourcePath] == null) {
sourceFilesArtifacts[data.sourcePath] = [];
}

sourceFilesArtifacts[data.sourcePath].push(data);
} catch (e) {
// JSON.parse throws SyntaxError objects
return e instanceof SyntaxError
? c(
new Error(
"Problem parsing artifact: " + jsonData[i].file
)
)
: c(e);
}
} catch (e) {
return c(e);
}

c();
Expand Down

0 comments on commit c7aa546

Please sign in to comment.