forked from platformio/platformio-core
Allow to pass project file path to run command instead project dir
This commit is contained in:
@ -38,7 +38,7 @@ from platformio.managers.platform import PlatformFactory
|
|||||||
default=getcwd,
|
default=getcwd,
|
||||||
type=click.Path(
|
type=click.Path(
|
||||||
exists=True,
|
exists=True,
|
||||||
file_okay=False,
|
file_okay=True,
|
||||||
dir_okay=True,
|
dir_okay=True,
|
||||||
writable=True,
|
writable=True,
|
||||||
resolve_path=True))
|
resolve_path=True))
|
||||||
@ -54,6 +54,13 @@ def cli(ctx, # pylint: disable=R0913,R0914
|
|||||||
silent,
|
silent,
|
||||||
verbose,
|
verbose,
|
||||||
disable_auto_clean):
|
disable_auto_clean):
|
||||||
|
# find project directory on upper level
|
||||||
|
if isfile(project_dir):
|
||||||
|
project_dir = util.find_project_dir_above(project_dir)
|
||||||
|
|
||||||
|
if not util.is_platformio_project(project_dir):
|
||||||
|
raise exception.NotPlatformIOProject(project_dir)
|
||||||
|
|
||||||
with util.cd(project_dir):
|
with util.cd(project_dir):
|
||||||
# clean obsolete .pioenvs dir
|
# clean obsolete .pioenvs dir
|
||||||
if not disable_auto_clean:
|
if not disable_auto_clean:
|
||||||
|
@ -194,6 +194,16 @@ def get_project_dir():
|
|||||||
return os.getcwd()
|
return os.getcwd()
|
||||||
|
|
||||||
|
|
||||||
|
def find_project_dir_above(path):
|
||||||
|
if isfile(path):
|
||||||
|
path = dirname(path)
|
||||||
|
if is_platformio_project(path):
|
||||||
|
return path
|
||||||
|
if isdir(dirname(path)):
|
||||||
|
return find_project_dir_above(dirname(path))
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def is_platformio_project(project_dir=None):
|
def is_platformio_project(project_dir=None):
|
||||||
if not project_dir:
|
if not project_dir:
|
||||||
project_dir = get_project_dir()
|
project_dir = get_project_dir()
|
||||||
|
Reference in New Issue
Block a user