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

Commit 7f833fd

Browse files
committed
optimize logic
1 parent 3131642 commit 7f833fd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/core/lib/console.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,18 @@ class Console extends EventEmitter {
264264
);
265265
const json = JSON.parse(body);
266266
const metadata = JSON.parse(json.metadata);
267+
const sources = Object.keys(metadata.sources);
267268
// filter out Truffle's console.log. We don't want users to interact with in the REPL.
268269
// user contracts named console.log will be imported, and a warning will be issued.
269270
if (
270-
!Object.keys(metadata.sources).some(source => {
271-
return (
272-
source === "truffle/console.sol" ||
273-
source === "truffle/Console.sol"
274-
);
275-
}) &&
276-
Object.keys(metadata.sources).length === 1
271+
sources.length > 1 ||
272+
(sources.length === 1 &&
273+
!sources.some(source => {
274+
return (
275+
source === "truffle/console.sol" ||
276+
source === "truffle/Console.sol"
277+
);
278+
}))
277279
) {
278280
jsonBlobs.push(json);
279281
}

0 commit comments

Comments
 (0)