Skip to content

Commit

Permalink
Cleanup automatically .pioenvs when platformio.ini has been changed /…
Browse files Browse the repository at this point in the history
…/ Issue #74
  • Loading branch information
ivankravets committed Feb 13, 2015
1 parent 2e90ab8 commit ae50b92
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions platformio/commands/run.py
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")
Expand All @@ -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()
Expand All @@ -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":
Expand Down

0 comments on commit ae50b92

Please sign in to comment.