Skip to content

Commit a982c44

Browse files
committed
"mbed new ." will import mbed-os only if the directory is empty
1 parent 5a14a1b commit a982c44

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

mbed/mbed.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,16 +973,17 @@ def new(name, tscm='git', depth=None, protocol=None):
973973
if p_path: # It's a library
974974
with cd(p_path):
975975
sync()
976-
else: # It's a program. Add mbed-os
976+
else: # It's a program
977977
# This helps sub-commands to display relative paths to the created program
978978
cwd_root = os.path.abspath(d_path)
979979

980-
try:
981-
with cd(d_path):
982-
add(mbed_os_url, depth=depth, protocol=protocol)
983-
except:
984-
rmtree_readonly(d_path)
985-
raise
980+
if len(os.listdir(d_path)) <= 1:
981+
try:
982+
with cd(d_path):
983+
add(mbed_os_url, depth=depth, protocol=protocol)
984+
except:
985+
rmtree_readonly(d_path)
986+
raise
986987
if d_path:
987988
os.chdir(d_path)
988989

0 commit comments

Comments
 (0)