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

Commit 8ebc466

Browse files
committed
don't load Truffle's console contract into the console environment
1 parent ac013dc commit 8ebc466

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/core/lib/console.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,20 @@ class Console extends EventEmitter {
262262
path.join(this.options.contracts_build_directory, file),
263263
"utf8"
264264
);
265-
jsonBlobs.push(JSON.parse(body));
265+
const json = JSON.parse(body);
266+
// hack to prevent a warning about the console.sol contract which we
267+
// don't load into the environment - we only want to do this when it is
268+
// Truffle's console.sol, that is why we check the sources keys
269+
if (
270+
!Object.keys(JSON.parse(json.metadata).sources).some(source => {
271+
return (
272+
source === "truffle/console.sol" ||
273+
source === "truffle/Console.sol"
274+
);
275+
})
276+
) {
277+
jsonBlobs.push(json);
278+
}
266279
} catch (error) {
267280
throw new Error(`Error parsing or reading ${file}: ${error.message}`);
268281
}

0 commit comments

Comments
 (0)