Change how we remove prettier pre-commit hook from the config (#4450)

This commit is contained in:
Bruno Alla 2023-08-01 20:56:51 +01:00 committed by GitHub
parent d54f29fd4f
commit bc56102f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -207,6 +207,24 @@ def handle_js_runner(choice, use_docker, use_async):
remove_gulp_files()
def remove_prettier_pre_commit():
with open(".pre-commit-config.yaml", "r") as fd:
content = fd.readlines()
removing = False
new_lines = []
for line in content:
if removing and "- repo:" in line:
removing = False
if "mirrors-prettier" in line:
removing = True
if not removing:
new_lines.append(line)
with open(".pre-commit-config.yaml", "w") as fd:
fd.writelines(new_lines)
def remove_celery_files():
file_names = [
os.path.join("config", "celery_app.py"),
@ -465,6 +483,7 @@ def main():
remove_webpack_files()
remove_sass_files()
remove_packagejson_file()
remove_prettier_pre_commit()
if "{{ cookiecutter.use_docker }}".lower() == "y":
remove_node_dockerfile()
else:

View File

@ -16,7 +16,6 @@ repos:
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key
{%- if cookiecutter.frontend_pipeline in ["Webpack", "Gulp"] %}
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
@ -24,7 +23,6 @@ repos:
- id: prettier
args: ['--tab-width', '2', '--single-quote']
exclude: '{{cookiecutter.project_slug}}/templates/'
{%- endif %}
- repo: https://github.com/adamchainz/django-upgrade
rev: '1.14.0'