Skip to content

Commit 3eb8dff

Browse files
samhocevarThomas Desveaux
authored and
Thomas Desveaux
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 8fbcfad commit 3eb8dff

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

nimp/environment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ def validate_uproject(self, urpoject):
382382
def display_unreal_info(self):
383383
'''display engine and selected uproject info'''
384384
if hasattr(self, 'unreal_full_version') and hasattr(self, 'unreal_dir'):
385-
logging.info(f'Found Unreal engine {self.unreal_full_version} in {self.unreal_dir}')
385+
logging.info(f'Found Unreal Engine {self.unreal_full_version} in {self.unreal_dir}')
386386
else:
387-
logging.info('No Unreal engine loaded')
387+
logging.info('No Unreal Engine found')
388388
if hasattr(self, 'uproject') and hasattr(self, 'uproject_dir'):
389389
logging.info(f'Found Unreal project {self.uproject} in {self.uproject_dir}')
390390
else:

nimp/unreal.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ def load_config(env):
4848
unreal_base_paths = [
4949
'UE',
5050
'UE4',
51-
'',
51+
'.',
5252
]
53-
for unreal_path in unreal_base_paths:
54-
unreal_dir = nimp.system.find_dir_containing_file(os.path.join(unreal_path, unreal_file))
55-
if unreal_dir:
56-
unreal_dir = os.path.join(unreal_dir, unreal_path)
57-
break
53+
for base in unreal_base_paths:
54+
path_to_base = nimp.system.find_dir_containing_file(os.path.join(base, unreal_file))
55+
if not path_to_base:
56+
continue
57+
# Sanity check: if `base` indicates a monorepo setup, check that it is really one
58+
if base != '.' and not os.path.isfile(os.path.join(path_to_base, '.nimp/monorepo_commands/__init__.py')):
59+
continue
60+
unreal_dir = os.path.join(path_to_base, base)
61+
break
5862

5963
if not unreal_dir:
6064
env.is_unreal = env.is_ue4 = env.is_ue5 = False

0 commit comments

Comments
 (0)