From 0f62910a56198d99c8a5568e203e7b2e614d5dd9 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Sun, 22 Sep 2019 14:50:31 -0400 Subject: [PATCH] Improve Bakefile detection logic If Bakefile is not found, None would be returned as a result of Bakefile.find(). --- bake/bakefile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bake/bakefile.py b/bake/bakefile.py index 325c3a7..8de279a 100644 --- a/bake/bakefile.py +++ b/bake/bakefile.py @@ -131,18 +131,20 @@ class Bakefile: @classmethod def find( - Class, *, filename="Bashfile", root=os.getcwd(), max_depth=4, topdown=False + Class, *, filename="Bakefile", root=os.getcwd(), max_depth=4, topdown=False ): """Returns the path of a Pipfile in parent directories.""" i = 0 for c, d, f in utils.walk_up(root): if i > max_depth: - raise NoBakefileFound(f"No {filename} found!") + break elif filename in f: return Class(path=os.path.join(c, filename)) i += 1 + raise NoBakefileFound(f"No {filename} found!") + @property def source(self): with open(self.path, "r") as f: