Skip to content

Commit 2d1235c

Browse files
committed
Disallow execution of mbed commands without program root
1 parent 4b28222 commit 2d1235c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

mbed/mbed.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,8 @@ def fromrepo(cls, path=None):
791791
repo.is_cwd = False
792792
else:
793793
path = os.getcwd()
794-
warning(
795-
"Could not find mbed program in current path. Assuming current dir.\n"
794+
error(
795+
"Could not find mbed program in current path.\n"
796796
"You can fix this by calling \"mbed new .\" or \"mbed default root .\" in the root of your program.")
797797

798798
repo.path = os.path.abspath(path)
@@ -1032,10 +1032,14 @@ def __init__(self, path=None, print_warning=False):
10321032
self.name = os.path.basename(self.path)
10331033

10341034
# is_cwd flag indicates that current dir is assumed to be root, not root repo
1035-
if self.is_cwd and print_warning:
1036-
warning(
1037-
"Could not find mbed program in current path. Assuming current dir.\n"
1035+
if self.is_cwd:
1036+
msg = (
1037+
"Could not find mbed program in current path.\n"
10381038
"You can fix this by calling \"mbed new .\" or \"mbed default root .\" in the root of your program.")
1039+
if print_warning:
1040+
warning(msg)
1041+
else:
1042+
error(msg)
10391043

10401044
# Sets config value
10411045
def set_cfg(self, var, val):

0 commit comments

Comments
 (0)