From 48b69ef5d8077679c4473f7880d634705539fa66 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Sat, 30 Dec 2023 19:47:22 -0500 Subject: [PATCH] Allow code_format.py to run from any directory --- code_format.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code_format.py b/code_format.py index 8c3d433..6f7d6b8 100755 --- a/code_format.py +++ b/code_format.py @@ -2,11 +2,15 @@ import argparse import black import subprocess +from pathlib import Path + +PROJECT_DIR = Path(__file__).parent.resolve() +SCUBAINIT_DIR = PROJECT_DIR / "scubainit" def _run_black(fix: bool) -> bool: args = [ - ".", + str(PROJECT_DIR), ] if not fix: @@ -38,7 +42,7 @@ def _rust_fmt(fix: bool) -> bool: "--check", ] - status = subprocess.call(args, cwd="scubainit") + status = subprocess.call(args, cwd=SCUBAINIT_DIR) if status == 0: print("Ok") return True