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

Invalid artifacts error #2118

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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