Skip to content

Commit

Permalink
Clear report folder
Browse files Browse the repository at this point in the history
Fixes #1502
  • Loading branch information
nvuillam committed Jul 17, 2022
1 parent 607c90c commit fea72eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ Configuration is assisted with auto-completion and validation in most commonly u
|------------------------------------------------------------|------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **ADDITIONAL_EXCLUDED_DIRECTORIES** | \[\] | List of additional excluded directory basenames. They are excluded at any nested level. |
| [**APPLY_FIXES**](#apply-fixes) | `none` | Activates formatting and auto-fixing [(more info)](#apply-fixes) |
| **CLEAR_REPORT_FOLDER** | `false` | Flag to clear files from report folder (usually megalinter-reports) before starting the linting process |
| **DEFAULT_BRANCH** | `HEAD` | Deprecated: The name of the repository's default branch. |
| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. |
| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. |
Expand Down
5 changes: 5 additions & 0 deletions megalinter/MegaLinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import multiprocessing as mp
import os
import shutil
import sys

import chalk as c
Expand Down Expand Up @@ -677,6 +678,10 @@ def initialize_output(self):
self.report_folder = self.arg_output
# Initialize output dir
os.makedirs(self.report_folder, exist_ok=True)
# Clear report folder if requested
if config.get("CLEAR_REPORT_FOLDER", "false") == "true":
shutil.rmtree(self.report_folder)
logging.debug(f"Emptied report folder {self.report_folder}")

def initialize_logger(self):
logging_level_key = config.get("LOG_LEVEL", "INFO").upper()
Expand Down

0 comments on commit fea72eb

Please sign in to comment.