@@ -106,23 +106,24 @@ def convert_filename(
106
106
filename = filename .relative_to (Path (crytic_compile .package_name ))
107
107
except ValueError :
108
108
pass
109
+
109
110
if not filename .exists ():
111
+ if cwd .joinpath (Path ("contracts" ), filename ).exists ():
112
+ filename = cwd .joinpath ("contracts" , filename )
113
+ elif working_dir .joinpath (filename ).exists ():
114
+ filename = working_dir .joinpath (filename )
110
115
# how node.js loads dependencies from node_modules:
111
116
# https://nodejs.org/api/modules.html#loading-from-node_modules-folders
112
- if cwd .joinpath (Path ("node_modules" ), filename ).exists ():
117
+ elif cwd .joinpath (Path ("node_modules" ), filename ).exists ():
113
118
filename = cwd .joinpath ("node_modules" , filename )
114
119
else :
115
- for folder in cwd .parents :
116
- if folder .joinpath (Path ("node_modules" ), filename ).exists ():
117
- filename = folder .joinpath (Path ("node_modules" ), filename )
120
+ for parent in cwd .parents :
121
+ if parent .joinpath (Path ("node_modules" ), filename ).exists ():
122
+ filename = parent .joinpath (Path ("node_modules" ), filename )
118
123
break
124
+
119
125
if not filename .exists ():
120
- if cwd .joinpath (Path ("contracts" ), filename ).exists ():
121
- filename = cwd .joinpath ("contracts" , filename )
122
- elif working_dir .joinpath (filename ).exists ():
123
- filename = working_dir .joinpath (filename )
124
- else :
125
- raise InvalidCompilation (f"Unknown file: { filename } " )
126
+ raise InvalidCompilation (f"Unknown file: { filename } " )
126
127
elif not filename .is_absolute ():
127
128
filename = cwd .joinpath (filename )
128
129
0 commit comments