Skip to content

Commit ed9a6f8

Browse files
author
bohendo
committed
implement hacky fix for monorepo issue
1 parent 04d6733 commit ed9a6f8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crytic_compile/utils/naming.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,21 @@ def convert_filename(
107107
except ValueError:
108108
pass
109109
if not filename.exists():
110+
# how node.js loads dependencies from node_modules:
111+
# https://nodejs.org/api/modules.html#loading-from-node_modules-folders
110112
if cwd.joinpath(Path("node_modules"), filename).exists():
111113
filename = cwd.joinpath("node_modules", filename)
114+
elif cwd.joinpath(Path("../node_modules"), filename).exists():
115+
filename = cwd.joinpath("contracts", filename)
116+
elif cwd.joinpath(Path("../../node_modules"), filename).exists():
117+
filename = cwd.joinpath("contracts", filename)
112118
elif cwd.joinpath(Path("contracts"), filename).exists():
113119
filename = cwd.joinpath("contracts", filename)
114120
elif working_dir.joinpath(filename).exists():
115121
filename = working_dir.joinpath(filename)
116122
else:
117-
raise InvalidCompilation(f"Unknown file: {filename}")
123+
test = cwd.joinpath(Path("../node_modules"), filename);
124+
raise InvalidCompilation(f"Unknown file: {filename} {test}")
118125
elif not filename.is_absolute():
119126
filename = cwd.joinpath(filename)
120127

0 commit comments

Comments
 (0)