Skip to content

Commit 1cdef43

Browse files
committed
Improve monorepo discovery
Protect against parent directories containing Unreal Engine source code without the current directory being part of a monorepo setup.
1 parent 3f3b4b7 commit 1cdef43

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

nimp/environment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ def validate_uproject(self, urpoject):
335335
def display_unreal_info(self):
336336
''' display engine and selected uproject info '''
337337
if hasattr(self, 'unreal_full_version') and hasattr(self, 'unreal_dir'):
338-
logging.info(f'Found Unreal engine {self.unreal_full_version} in {self.unreal_dir}')
338+
logging.info(f'Found Unreal Engine {self.unreal_full_version} in {self.unreal_dir}')
339339
else:
340-
logging.info('No Unreal engine loaded')
340+
logging.info('No Unreal Engine found')
341341
if hasattr(self, 'uproject') and hasattr(self, 'uproject_dir'):
342342
logging.info(f'Found Unreal project {self.uproject} in {self.uproject_dir}')
343343
else:

nimp/unreal.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ def load_config(env):
4747
unreal_base_paths = [
4848
'UnrealEngine',
4949
'UE4',
50-
'',
50+
'.',
5151
]
52-
for unreal_path in unreal_base_paths:
53-
unreal_dir = nimp.system.find_dir_containing_file(os.path.join(unreal_path, unreal_file))
54-
if unreal_dir:
55-
unreal_dir = os.path.join(unreal_dir, unreal_path)
56-
break
57-
58-
if not unreal_dir:
52+
for base in unreal_base_paths:
53+
path_to_base = nimp.system.find_dir_containing_file(os.path.join(base, unreal_file))
54+
if not path_to_base:
55+
continue
56+
# Sanity check: if `base` indicates a monorepo setup, check that it is really one
57+
if base != '.' and not os.path.isfile(os.path.join(path_to_base, '.nimp/monorepo_commands/__init__.py')):
58+
continue
59+
unreal_dir = os.path.join(path_to_base, base)
60+
break
61+
finally:
5962
env.is_unreal = env.is_ue4 = env.is_ue5 = False
6063
env.is_dne_legacy_ue4 = True
6164
return True

0 commit comments

Comments
 (0)