-
-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup automatically .pioenvs when platformio.ini has been changed /…
…/ Issue #74
- Loading branch information
1 parent
2e90ab8
commit ae50b92
Showing
1 changed file
with
10 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
# Copyright (C) Ivan Kravets <[email protected]> | ||
# See LICENSE for details. | ||
|
||
from os.path import getmtime, join | ||
from shutil import rmtree | ||
|
||
import click | ||
|
||
from platformio import app, exception, telemetry | ||
from platformio import app, exception, telemetry, util | ||
from platformio.commands.install import cli as cmd_install | ||
from platformio.platforms.base import PlatformFactory | ||
from platformio.util import get_project_config | ||
|
||
|
||
@click.command("run", short_help="Process project environments") | ||
|
@@ -16,7 +18,7 @@ | |
@click.pass_context | ||
def cli(ctx, environment, target, upload_port): | ||
|
||
config = get_project_config() | ||
config = util.get_project_config() | ||
|
||
if not config.sections(): | ||
raise exception.ProjectEnvsNotAvailable() | ||
|
@@ -25,6 +27,11 @@ def cli(ctx, environment, target, upload_port): | |
if unknown: | ||
raise exception.UnknownEnvNames(", ".join(unknown)) | ||
|
||
# remove ".pioenvs" if project config is modified | ||
if (getmtime(join(util.get_project_dir(), "platformio.ini")) > | ||
getmtime(util.get_pioenvs_dir())): | ||
rmtree(util.get_pioenvs_dir()) | ||
|
||
for section in config.sections(): | ||
# skip main configuration section | ||
if section == "platformio": | ||
|